Inheritance: Microsoft.Test.CommandLineParsing.Command
Exemple #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintCommands();
                return;
            }

            Command c = null;

            if (string.Compare(args[0], "split", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new SplitCommand();
            }
            else if (string.Compare(args[0], "expand", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new ExpandCommand();
            }
            else if (string.Compare(args[0], "stem", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new StemCommand();
            }
            else if (string.Compare(args[0], "scratch", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new ScratchCommand();
            }
            else if (string.Equals(args[0], "GetIdentifiers", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new GetIdentifiersCommand();
            }
            else if (string.Equals(args[0], "AnalyzeFunctions", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new AnalyzeFunctionsCommand();
            }
            //else if (string.Equals(args[0], "CountProgramWords", StringComparison.InvariantCultureIgnoreCase))
            //{
            //    c = new CountProgramWordsCommand();
            //}
            else if (string.Equals(args[0], "Random", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new RandomCommand();
            }
            else if (string.Equals(args[0], "swum", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new SwumCommand();
            }
            else
            {
                PrintCommands();
            }

            if (c == null)
            {
                return;
            }
            else
            {
                try
                {
                    c.ParseArguments(args.Skip(1));
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                    CommandLineParser.PrintUsage(c);
                    return;
                }

                c.Execute();
            }

            return;
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintCommands();
                return;
            }

            Command c = null;
            if (string.Compare(args[0], "split", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new SplitCommand();
            }
            else if (string.Compare(args[0], "expand", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new ExpandCommand();
            }
            else if (string.Compare(args[0], "stem", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new StemCommand();
            }
            else if (string.Compare(args[0], "scratch", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                c = new ScratchCommand();
            }
            else if (string.Equals(args[0], "GetIdentifiers", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new GetIdentifiersCommand();
            }
            else if (string.Equals(args[0], "AnalyzeFunctions", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new AnalyzeFunctionsCommand();
            }
            //else if (string.Equals(args[0], "CountProgramWords", StringComparison.InvariantCultureIgnoreCase))
            //{
            //    c = new CountProgramWordsCommand();
            //}
            else if (string.Equals(args[0], "Random", StringComparison.InvariantCultureIgnoreCase))
            {
                c = new RandomCommand();
            } else if(string.Equals(args[0], "swum", StringComparison.InvariantCultureIgnoreCase)) {
                c = new SwumCommand();
            } else {
                PrintCommands();
            }

            if (c == null) { return; }
            else
            {
                try
                {
                    c.ParseArguments(args.Skip(1));
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                    CommandLineParser.PrintUsage(c);
                    return;
                }

                c.Execute();
            }

            return;

        }