From 342f8246db4610b7e4e009e12d214068d42cc775 Mon Sep 17 00:00:00 2001 From: "Joel W. Reed" Date: Thu, 12 Jul 2007 12:18:17 -0400 Subject: [PATCH] add command aliases --- tools/tf/ChangesetCommand.cs | 2 +- tools/tf/CheckoutCommand.cs | 2 +- tools/tf/CommandAttribute.cs | 18 ++++++++++++++++-- tools/tf/CommandRegistry.cs | 6 ++++-- tools/tf/DeleteCommand.cs | 2 +- tools/tf/DiffCommand.cs | 6 +++--- tools/tf/Driver.cs | 4 ++-- tools/tf/HistoryCommand.cs | 2 +- tools/tf/RenameCommand.cs | 2 +- tools/tf/StatusCommand.cs | 2 +- 10 files changed, 31 insertions(+), 15 deletions(-) diff --git a/tools/tf/ChangesetCommand.cs b/tools/tf/ChangesetCommand.cs index fedb672..249d171 100644 --- a/tools/tf/ChangesetCommand.cs +++ b/tools/tf/ChangesetCommand.cs @@ -34,7 +34,7 @@ using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; [Command("changeset", "Show changeset details: committer, date, comment, and files changed.")] -class ChangesetCommand : DiffCommand +class ChangesetCommand : DifferenceCommand { public ChangesetCommand(string[] arguments, TfOptions options, VersionControlServer vcs): diff --git a/tools/tf/CheckoutCommand.cs b/tools/tf/CheckoutCommand.cs index 7840783..97c4a98 100644 --- a/tools/tf/CheckoutCommand.cs +++ b/tools/tf/CheckoutCommand.cs @@ -33,7 +33,7 @@ using System.Text; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; -[Command("checkout", "Checkout a file for editing.")] +[Command("checkout", "Checkout a file for editing.", "edit")] class CheckoutCommand : Command { public CheckoutCommand(string[] arguments, TfOptions options, diff --git a/tools/tf/CommandAttribute.cs b/tools/tf/CommandAttribute.cs index e56506b..9636b97 100644 --- a/tools/tf/CommandAttribute.cs +++ b/tools/tf/CommandAttribute.cs @@ -30,19 +30,33 @@ using System; [AttributeUsage(AttributeTargets.Class)] public class CommandAttribute : Attribute { + private string name; + private string description; + private string alias; + public CommandAttribute(string name, string description) { this.name = name; this.description = description; } - private string name; + public CommandAttribute(string name, string description, string alias) + { + this.name = name; + this.description = description; + this.alias = alias; + } + public string Name { get { return name; } } - private string description; + public string Alias + { + get { return alias; } + } + public string Description { get { return description; } diff --git a/tools/tf/CommandRegistry.cs b/tools/tf/CommandRegistry.cs index 3328a4c..4969b1e 100644 --- a/tools/tf/CommandRegistry.cs +++ b/tools/tf/CommandRegistry.cs @@ -48,8 +48,10 @@ public class CommandRegistry CommandAttribute[] attributes = t.GetCustomAttributes(typeof(CommandAttribute), false) as CommandAttribute[]; foreach (CommandAttribute attribute in attributes) { - Console.WriteLine(" " + attribute.Name); - + Console.Write(" " + attribute.Name); + if (!String.IsNullOrEmpty(attribute.Alias)) Console.Write(" (alias {0})", attribute.Alias); + Console.WriteLine(); + string description = attribute.Description; int x = 0; diff --git a/tools/tf/DeleteCommand.cs b/tools/tf/DeleteCommand.cs index c64df06..cf90a4a 100644 --- a/tools/tf/DeleteCommand.cs +++ b/tools/tf/DeleteCommand.cs @@ -33,7 +33,7 @@ using System.Text; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; -[Command("delete", "Pend a delete against a file or files.")] +[Command("delete", "Pend a delete against a file or files.", "del")] class DeleteCommand : Command { public DeleteCommand(string[] arguments, TfOptions options, diff --git a/tools/tf/DiffCommand.cs b/tools/tf/DiffCommand.cs index 49dd9d0..669307c 100644 --- a/tools/tf/DiffCommand.cs +++ b/tools/tf/DiffCommand.cs @@ -7,10 +7,10 @@ using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Common; using Microsoft.TeamFoundation.VersionControl.Client; -[Command("diff", "Show pending changes, latest on server, a changeset, or local changes not pended as a unified diff.")] -class DiffCommand : Command +[Command("difference", "Show pending changes, latest on server, a changeset, or local changes not pended as a unified diff.", "diff")] +class DifferenceCommand : Command { - public DiffCommand(string[] arguments, TfOptions options, + public DifferenceCommand(string[] arguments, TfOptions options, VersionControlServer vcs): base(arguments, options, vcs) { diff --git a/tools/tf/Driver.cs b/tools/tf/Driver.cs index 41961e4..c40b6a1 100644 --- a/tools/tf/Driver.cs +++ b/tools/tf/Driver.cs @@ -251,10 +251,10 @@ partial class Driver : ICertificatePolicy command = new DeleteCommand(cmdArgs, Options, vcs); break; case "diff": // command alias - command = new DiffCommand(cmdArgs, Options, vcs); + command = new DifferenceCommand(cmdArgs, Options, vcs); break; case "difference": - command = new DiffCommand(cmdArgs, Options, vcs); + command = new DifferenceCommand(cmdArgs, Options, vcs); break; case "dir": command = new DirCommand(cmdArgs, Options, vcs); diff --git a/tools/tf/HistoryCommand.cs b/tools/tf/HistoryCommand.cs index 09fa46f..6096452 100644 --- a/tools/tf/HistoryCommand.cs +++ b/tools/tf/HistoryCommand.cs @@ -35,7 +35,7 @@ using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; using Microsoft.TeamFoundation.VersionControl.Common; -[Command("history", "Display changelog history for specified file.")] +[Command("history", "Display changelog history for specified file.", "hist")] class HistoryCommand : Command { public HistoryCommand(string[] arguments, TfOptions options, diff --git a/tools/tf/RenameCommand.cs b/tools/tf/RenameCommand.cs index fb92eef..5a64091 100644 --- a/tools/tf/RenameCommand.cs +++ b/tools/tf/RenameCommand.cs @@ -33,7 +33,7 @@ using System.Text; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; -[Command("rename", "Rename a file or files in the repository.")] +[Command("rename", "Rename a file or files in the repository.", "move")] class RenameCommand : Command { public RenameCommand(string[] arguments, TfOptions options, diff --git a/tools/tf/StatusCommand.cs b/tools/tf/StatusCommand.cs index a3a81f9..5f51505 100644 --- a/tools/tf/StatusCommand.cs +++ b/tools/tf/StatusCommand.cs @@ -43,7 +43,7 @@ public class KvpComparer: IComparer> } } -[Command("status", "Show status of all pending changes in local workspace.")] +[Command("status", "Show status of all pending changes in local workspace.", "stat")] class StatusCommand : Command { public StatusCommand(string[] arguments, TfOptions options, -- 2.11.4.GIT