Create a commands map to respond to `conify help` with.
506460
def create_commands_map
      # Require all the ruby command files
      command_file_paths.each do |file|
        require file

        # Get basename for the file without the extension
        basename = get_basename_from_file(file)

        # Camelcase the basename to be the klass name
        klass_name = camelize(basename)

        # return the command klass for this klass_name
        command_klass = Conify::Command.const_get(klass_name)

        # For each of the user-defined methods inside this class, create a command for it
        manually_added_methods(command_klass).each { |method|
          register_command(basename, method.to_s, command_klass, global: basename == 'global')
        }
      end
    end
789933
def make_command(command: Callable) -> Callable:
    """"""
    @wraps(command)
    def actualcommand(self, *args, **kwds):  # pylint: disable=missing-docstring
        data = command(self, *args, **kwds)
        name = command.__name__[3:]
        signal = '{uuid}{sep}{event}'.format(
            uuid=self._uuid,  # pylint: disable=protected-access
            sep=SEPARATOR,
            event=name
        )
        if flask.has_request_context():
            emit(signal, {'data': pack(data)})
        else:
            sio = flask.current_app.extensions['socketio']
            sio.emit(signal, {'data': pack(data)})
        eventlet.sleep()

    return actualcommand
464057
def linkify_one_command_with_commands(self, commands, prop):
        

        if not hasattr(self, prop):
            return

        command = getattr(self, prop).strip()
        if not command:
            setattr(self, prop, None)
            return

        data = {"commands": commands, "call": command}
        if hasattr(self, 'poller_tag'):
            data.update({"poller_tag": self.poller_tag})
        if hasattr(self, 'reactionner_tag'):
            data.update({"reactionner_tag": self.reactionner_tag})

        setattr(self, prop, CommandCall(data))
605735
function Command(name, parent) {
  if (!(this instanceof Command)) {
    return new Command();
  }
  this.commands = [];
  this.options = [];
  this._args = [];
  this._aliases = [];
  this._name = name;
  this._relay = false;
  this._hidden = false;
  this._parent = parent;
  this._mode = false;
  this._catch = false;
  this._help = undefined;
  this._init = undefined;
  this._after = undefined;
  this._allowUnknownOptions = false;
}
310666
protected void generalHelp(AsciiTable at){
		//collect all commands belonging to a particular category
		String defKey = "__standard";
		Map<String, TreeMap<String, SkbShellCommand>> cat2Cmd = new TreeMap<>();
		for(CommandInterpreter ci : this.skbShell.getCommandMap().values()){
			for(SkbShellCommand ssc : ci.getCommands().values()){
				String cat = defKey;
				if(ssc.getCategory()!=null){
					cat = ssc.getCategory().getCategory();
				}
				if(!cat2Cmd.containsKey(cat)){
					cat2Cmd.put(cat, new TreeMap<>());
				}
				cat2Cmd.get(cat).put(ssc.getCommand(), ssc);
			}
		}

		//no argument, means general help
		at.addRow(null, this.skbShell.getDisplayName() + "-" + this.skbShell.getDescription());
		at.addRule();

		//do the commands per category, starting with "__standard"
		for(String cat : cat2Cmd.keySet()){
			String catDescr = cat;
			if(defKey.equals(cat)){
				catDescr = "standard commands";
			}
			at.addRow(catDescr, new StrBuilder().appendWithSeparators(cat2Cmd.get(cat).keySet(), ", "));
			at.addRule();
		}
		at.addRow(null, "try: 'help <command>' for more details");
	}
1050623
def execute_flow(self, custom_command="", is_config=False):
        

        responses = []
        if isinstance(custom_command, str):
            commands = [custom_command]
        elif isinstance(custom_command, tuple):
            commands = list(custom_command)
        else:
            commands = custom_command

        if is_config:
            mode = self._cli_handler.config_mode
            if not mode:
                raise Exception(self.__class__.__name__,
                                "CliHandler configuration is missing. Config Mode has to be defined")
        else:
            mode = self._cli_handler.enable_mode
            if not mode:
                raise Exception(self.__class__.__name__,
                                "CliHandler configuration is missing. Enable Mode has to be defined")

        with self._cli_handler.get_cli_service(mode) as session:
            for cmd in commands:
                responses.append(session.send_command(command=cmd))
        return '\n'.join(responses)
1176268
def add_commands(self):
        
        self.parser.add_argument(
            '-d',
            action="count",
            **self.config.default.debug.get_arg_parse_arguments())
378044
def _create_request_map(cls, input_map):
        """"""
        field_map = cls._get_attributes_map()
        return {field_map[k]: v for k, v in input_map.items() if k in field_map}
1037900
function help() {
    var padBtm = [0, 0, 1, 0];
    var msg = ' See additional required/optional arguments for each command below. \n';
    pargv
        .logo('Mustr', 'cyan')
        .ui(95)
        .join(chalk.magenta('Usage:'), 'mu', chalk.cyan('<cmd>'), '\n')
        .div({ text: chalk.bgBlue.white(msg) })
        .div({ text: chalk.cyan('help, h'), width: 35, padding: padBtm }, { text: chalk.gray('displays help and usage information.'), width: 40, padding: padBtm })
        .div({ text: chalk.cyan('init, i'), width: 35, padding: padBtm }, { text: chalk.gray('initialize the application for use with Mustr.'), width: 40, padding: padBtm })
        .div({ text: chalk.cyan('generate, g') + " " + chalk.white('<template>') + " " + chalk.magenta('[output]'), width: 35, padding: padBtm }, { text: chalk.gray('generates and renders a template.'), width: 40, padding: padBtm })
        .div({ text: chalk.white('<template>'), width: 35, padding: [0, 2, 0, 2] }, { text: chalk.gray('template to generate and compile.'), width: 40 }, { text: chalk.red('[required]'), align: 'right' })
        .div({ text: chalk.white('[output]'), width: 35, padding: [0, 2, 0, 2] }, { text: chalk.gray('output name/path for template'), width: 40, padding: padBtm })
        .div({ text: chalk.cyan('rollback, r') + " " + chalk.white('<name/id>') + " " + chalk.magenta('[output]'), width: 35, padding: padBtm }, { text: chalk.gray('Rolls back a template or component.'), width: 40, padding: padBtm })
        .div({ text: chalk.white('<name/id>'), width: 35, padding: [0, 2, 0, 2] }, { text: chalk.gray('the rollback id, index or template name.'), width: 40 })
        .div({ text: chalk.white('[output]'), width: 35, padding: [0, 2, 0, 2] }, { text: chalk.gray('output name/path for template'), width: 40, padding: padBtm })
        .div({ text: chalk.cyan('show, s') + " " + chalk.white('<type>'), width: 35, padding: padBtm }, { text: chalk.gray('shows details/stats for the given type.'), width: 40, padding: padBtm })
        .div({ text: chalk.white('<type>'), width: 35, padding: [0, 2, 0, 2] }, { text: chalk.gray('currently there is only one type "rollbacks"'), width: 40 })
        .show();
}
780430
function commandFactory(combos, cmd)
{
  var command;

  // if no combos provided
  // consider it as a single command run
  if (!cmd)
  {
    cmd = combos;
    combos = [{}];
  }

  command = partial(iterate, combos, cmd);
  command.commandDescription = partial(commandDescription, cmd);
  return command;
}
36835
function(c){
        var args = [];
        /* command acceptance */
        args.push((c.cmd.short ? c.cmd.short+', ' : '')+c.cmd.long + ' [value]');
        /* command help message */
        args.push((c.cmd.help ? c.cmd.help : c.prompt.message));
        return args;
      }
37601
def help(self, event, command_name=None):
        
        if command_name is None:
            return ("Type !commands for a list of all commands. Type "
                    "!help [command] to see help for a specific command.")
        try:
            command = self.commands_dict()[command_name]
        except KeyError:
            return "%s is not a command" % command_name

        argspec = getargspec(command)
        args = argspec.args[2:]
        defaults = argspec.defaults or []
        for i in range(-1, -len(defaults) - 1, -1):
            args[i] = "%s [default: %s]" % (args[i], defaults[i])
        args = ", ".join(args)
        help = getdoc(command).replace("\n", " ")
        return "help for %s: (args: %s) %s" % (command_name, args, help)
1109230
def cli(ctx):
    """"""
    cmd = click.prompt('Command')
    desc = click.prompt('Description ')
    alias = click.prompt('Alias (optional)', default='')
    utils.save_command(cmd, desc, alias)

    utils.log(ctx, 'Saved the new command - {} - with the description - {}.'.format(cmd, desc))
1065288
def _cli_command(commands,
                 method='cli',
                 **kwargs):
    '''
    
    '''
    if not isinstance(commands, (list, tuple)):
        commands = [commands]
    rpc_responses = rpc(commands,
                        method=method,
                        **kwargs)
    txt_responses = []
    for rpc_reponse in rpc_responses:
        error = rpc_reponse.get('error')
        if error:
            cmd = rpc_reponse.get('command')
            if 'data' in error:
                msg = 'The command "{cmd}" raised the error "{err}".'.format(cmd=cmd, err=error['data']['msg'])
                raise SaltException(msg)
            else:
                msg = 'Invalid command: "{cmd}".'.format(cmd=cmd)
                raise SaltException(msg)
        txt_responses.append(rpc_reponse['result'])
    return txt_responses
127023
def help(self):
        ''''''
        cmds = self.get_exposed_cmds()
        t = text_helper.Table(fields=['command', 'doc'],
                              lengths=[50, 85])
        return t.render((reflect.formatted_function_name(x), x.__doc__, )
                        for x in cmds.values())
734061
function _preCommand(commands) {
  commander.on('--help', function () {

    var hasExample = _.map(_.values(commands), 'examples')
      .filter(function (elem) {
        return elem !== undefined;
      });
    if (hasExample.length > 0) {
      hasExample = hasExample.reduce(function (a, b) {
        return a.concat(b);
      });
    }
    hasExample = hasExample.length > 0;

    if (hasExample) {

      console.log('  Examples:\n');

      Object.keys(commands).forEach(function (command) {
        if (!_.isEmpty(commands[command].examples)) {
          console.log('    %s:', command);
          commands[command].examples.forEach(function (example) {
            console.log('      %s', example);
          });
        }
      });
    }
  });
}
547530
def help(context, command):
    ''''''
    if command:
        cmd = cli.commands.get(command, None)
        if cmd:
            context.info_name = command
            click.echo(cmd.get_help(context))
        else:
            raise click.ClickException('no command: %s' % command)
    else:
        click.echo(cli.get_help(context))