public static void Main(string[] args) { CommandBase[] cmdList = { new ShowUsageCommand(), new ListTeamCommand(), new CreateTeamCommand(), new DeleteTeamCommand(), new RenameTeamCommand(), new GetDefaultTeamCommand(), new SetDefaultTeamCommand(), new AddUserCommand(), new RemoveUserCommand(), new ListTeamMembersCommand(), new ListTeamAdminCommand(), new AddTeamAdminCommand(), new RemoveTeamAdminCommand(), new ListTeamMembersCommand(), new ClearProfileImageCommand(), new SetProfileImageCommand(), new ClearTeamImageCommand(), new SetTeamImageCommand(), new GroupToTeamCommand() }; if (args == null) { throw new ArgumentNullException("args"); } if (!args.Any()) { ShowUsageCommand cmd = new ShowUsageCommand(); cmd.Run(); } else if (args[0] == @"/?") { ShowUsageCommand cmd = new ShowUsageCommand(); cmd.Run(); } else { bool cmdFound = false; foreach (CommandBase cmd in cmdList) { if (args[0].ToUpper() == cmd.CommandName.ToUpper()) { cmdFound = true; List <string> lstArg = new List <string>(); lstArg.AddRange(args); lstArg.RemoveAt(0); if (cmd.ParseArguments(lstArg.ToArray())) { if (cmd.Validate()) { cmd.Run(); } } } } if (cmdFound != true) { Console.WriteLine("Unknown command: " + args[0]); Console.WriteLine("Try running TfsTeams /?"); } } }
public static void Main(string[] args) { CommandBase[] cmdList = new CommandBase[] { new ShowUsageCommand(), new ListTeamCommand(), new CreateTeamCommand(), new DeleteTeamCommand(), new RenameTeamCommand(), new GetDefaultTeamCommand(), new SetDefaultTeamCommand(), new AddUserCommand(), new RemoveUserCommand(), new ListTeamMembersCommand() }; if (args == null) { throw new ArgumentNullException("args"); } if (!args.Any()) { ShowUsageCommand cmd = new ShowUsageCommand(); cmd.Run(); } else if (args[0] == @"/?") { ShowUsageCommand cmd = new ShowUsageCommand(); cmd.Run(); } else { bool cmdFound = false; foreach (CommandBase cmd in cmdList) { if (args[0].ToUpper() == cmd.CommandName.ToUpper()) { cmdFound = true; List <string> lstArg = new List <string>(); lstArg.AddRange(args); lstArg.RemoveAt(0); if (cmd.ParseArguments(lstArg.ToArray())) { if (cmd.Validate()) { cmd.Run(); } } } } if (cmdFound != true) { Console.WriteLine("Unknown command: " + args[0]); Console.WriteLine("Try running TfsTeams /?"); } //switch (args[0].ToUpper()) //{ // case "LISTTEAMS": // cmd = new ListTeamCommand(); // break; // case "CREATETEAM": // cmd = new CreateTeamCommand(); // break; // case "ADDUSER": // cmd = new AddUserCommand(); // break; // default: // cmd = new ShowUsageCommand(); // break; //} } }