give command only its args not all args
[tfs.git] / tools / tf / PropertiesCommand.cs
blob5760086f14d7daf2ac225a8112b1c82f6b056b0c
1 //
2 // PropertiesCommand.cs
3 //
4 // Authors:
5 // Joel Reed (joelwreed@gmail.com)
6 //
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.Collections.Generic;
31 using System.IO;
32 using System.Text;
33 using Microsoft.TeamFoundation.Client;
34 using Microsoft.TeamFoundation.VersionControl.Client;
35 using Microsoft.TeamFoundation.VersionControl.Common;
37 [Command("properties", "Show detailed properties for each filename including server locks, encoding, last modified date, changeset id, and whether the file has a newer version on the server.")]
38 class PropertiesCommand : Command
40 public PropertiesCommand(Driver driver, string[] args): base(driver, args)
44 public override void Run()
46 Workspace workspace = GetWorkspaceFromCache();
48 // process command options
49 DeletedState dstate = Options.Deleted ? DeletedState.Any : DeletedState.NonDeleted;
50 RecursionType rtype = Options.Recursive ? RecursionType.Full : RecursionType.OneLevel;
52 List<ItemSpec> itemSpecs = new List<ItemSpec>();
53 for (int i = 1; i < Arguments.Length; i++)
55 string path = Arguments[i];
56 if (!VersionControlPath.IsServerItem(path)) path = Path.GetFullPath(path);
57 itemSpecs.Add(new ItemSpec(path, rtype));
60 ExtendedItem[][] items = workspace.GetExtendedItems(itemSpecs.ToArray(),
61 dstate, ItemType.Any);
62 if (items.Length == 0)
64 Console.WriteLine("No items match " + Arguments[1]);
65 Environment.Exit(-1);
68 foreach (ExtendedItem[] itemArray in items)
70 foreach (ExtendedItem item in itemArray)
72 Console.WriteLine("Local information:");
73 Console.WriteLine(" Local path : " + item.LocalItem);
74 Console.WriteLine(" Server path: " + item.TargetServerItem);
75 Console.WriteLine(" Changeset : " + item.VersionLocal);
76 Console.WriteLine(" Change : " + item.ChangeType.ToString().ToLower());
77 Console.WriteLine(" Type : " + item.ItemType.ToString().ToLower());
79 Console.WriteLine("Server information:");
80 Console.WriteLine(" Server path : " + item.SourceServerItem);
81 Console.WriteLine(" Changeset : " + item.VersionLatest);
82 Console.WriteLine(" Deletion Id : " + item.DeletionId);
83 Console.WriteLine(" Lock : " + item.LockStatus.ToString().ToLower());
84 Console.WriteLine(" Lock Owner : " + item.LockOwner);
85 Console.WriteLine(" Last Modified: Not Implemented");
86 Console.WriteLine(" Type : " + item.ItemType.ToString().ToLower());
88 Encoding encoding = Encoding.GetEncoding(item.Encoding);
89 Console.WriteLine(" File type : " + encoding.HeaderName);
91 long len = 0;
92 if (!String.IsNullOrEmpty(item.LocalItem))
94 FileInfo fi = new FileInfo(item.LocalItem);
95 len = fi.Length;
98 Console.WriteLine(" Size : " + Convert.ToString(len));