예제 #1
0
        static void Main(string[] args)
        {
            CommandContext context = CommandContext.CreateContext();

            // Parse the command line
            context.ParseArguments(args);

            // Validate the command line against what was identified in teh configuraiton.json or any other
            // commands that have been added. User gets one chance to correct bad input for each command
            context.Validate();

            // Get each of the commands and print something about them. In this case
            // COMMAND LINE: -d -b
            // -d -> uses it's default value
            // -b -> prompts for input
            // -c -> does not return a value because it's not present or required
            foreach (string cmd in ExpectedCommands)
            {
                MenuItem item = context.GetMenuItem(cmd);
                if (item == null)
                {
                    Console.WriteLine("Command is not present: {0}", cmd);
                }
                else
                {
                    object commandValue = item.GetCommandValue();
                    Console.WriteLine("{0} == {1}", item.Command, commandValue != null? commandValue.ToString() : "null");
                }
            }
        }