Пример #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();
            }
        }
Пример #2
0
        public void Help(string[] args)
        {
            string cmdName = null;

            if (!args.IsNullOrEmpty())
            {
                cmdName = args[0];
            }

            if (string.IsNullOrEmpty(cmdName))
            {
                Console.WriteLine(HelpUsage);
                return;
            }

            if (cmdName.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                ShowAllUsage();
                return;
            }

            CommandDef cmd = this[cmdName];

            if (cmd != null)
            {
                cmd.ShowUsage();
                return;
            }
            //
            // Do a prefix match. Note: if needed, we can speed this up since the name array is sorted.
            //
            foreach (string name in this.PrefixMatchCommandNames(cmdName))
            {
                this.Bind(name).ShowUsage();
            }
        }