Example #1
0
 internal Command(string command, string help, string syntax, DashCMDCommand callback, bool hideInHelp)
 {
     this.command    = command;
     this.help       = help;
     this.hideInHelp = hideInHelp;
     this.callback   = callback;
     this.syntax     = syntax;
     this.core       = false;
 }
Example #2
0
        /// <summary>
        /// Adds a command with this cmd.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="help">The help message to show when the help command is used.</param>
        /// <param name="syntax">The syntax message to show when the --syntax argument
        /// is used with this command.</param>
        /// <param name="callback">Method to call when the command is used.</param>
        /// <exception cref="System.ArgumentException"></exception>
        public static void AddCommand(string command, string help, string syntax, DashCMDCommand callback)
        {
            if (commands.ContainsKey(command))
            {
                throw new ArgumentException(String.Format("Command already registered: {0}", command));
            }

            commands.Add(command, new Command(command,
                                              !String.IsNullOrWhiteSpace(help) ? help : "",
                                              !String.IsNullOrWhiteSpace(syntax) ? syntax : command,
                                              callback,
                                              String.IsNullOrWhiteSpace(help)));
        }
Example #3
0
        /// <summary>
        /// Adds a command with this cmd.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="callback">Method to call when the command is used.</param>
        /// <exception cref="System.ArgumentException"></exception>
        public static void AddCommand(string command, DashCMDCommand callback)
        {
            if (commands.ContainsKey(command))
            {
                throw new ArgumentException("Command already registered!");
            }

            commands.Add(command, new Command(command,
                                              "",
                                              command,
                                              callback,
                                              true));
        }