Exemple #1
0
        public void Eval(params string[] input)
        {
            if (input.IsNullOrEmpty())
            {
                return;
            }

            string     commandName = input.First();
            CommandDef cmd         = this[commandName];

            if (cmd == null)
            {
                this.ShowUsageCommandNotFound(commandName);
                return;
            }

            try
            {
                cmd.Eval((input.Select(arg => arg)).Skip(1).ToArray());
            }
            catch (Exception ex)
            {
                this.HandleError(ex);
                CommandUI.PrintSectionBreak();
                cmd.ShowUsage();
            }
        }
Exemple #2
0
        void ShowAllUsage()
        {
            CommandUI.PrintHeading("Registered commands");

            foreach (string name in this.CommandNames)
            {
                this.ShowUsage(name);
            }
        }
Exemple #3
0
        internal void ShowUsage()
        {
            CommandUI.PrintUpperCase(this.Name);
            if (this.UsageFunctor != null)
            {
                Console.WriteLine(this.UsageFunctor());
            }

            Console.WriteLine();
        }
Exemple #4
0
 void HandleError(Exception ex)
 {
     if (this.Error != null)
     {
         this.Error(ex);
     }
     else
     {
         CommandUI.Print(ex);
     }
 }
Exemple #5
0
        public void RunInteractive()
        {
            CommandUI.PrintHeading(m_appName);

            string input;

            while ((input = CommandUI.GetInput()) != null)
            {
                if (input.Length > 0)
                {
                    this.Run(input);
                }
            }
        }
Exemple #6
0
 void ShowUsageCommandNotFound(string commandName)
 {
     Console.WriteLine();
     CommandUI.PrintUpperCase("{0}:  No such command.", commandName);
     CommandUI.PrintSectionBreak();
     //
     // Speculatively print out names of commands with this prefix..
     //
     if (this.PrefixMatchCommandNames(commandName).FirstOrDefault() != null)
     {
         //
         // Speculatively print out names of commands with this prefix..
         //
         CommandUI.PrintHeading("Did you mean?");
         this.ListCommands(new string[] { commandName });
     }
     else
     {
         Console.WriteLine(HelpUsage);
     }
 }
Exemple #7
0
 internal void ShowCommand()
 {
     CommandUI.PrintUpperCase(this.Name);
 }