Prints the documentation of the given command

        :param session: Session handler
        :param namespace: Name space of the command
        :param cmd_name: Name of the command
540274
def __print_command_help(self, session, namespace, cmd_name):
        
        # Extract documentation
        args, doc = self.__extract_help(self._commands[namespace][cmd_name])

        # Print the command name, and its arguments
        if args:
            session.write_line("- {0} {1}", cmd_name, args)
        else:
            session.write_line("- {0}", cmd_name)

        # Print the documentation line
        session.write_line("\t\t{0}", doc)
494522
def do_help(self, *cmd_names: str) -> None:
        
        def _h(cmd: str, template: str) -> None:
            try:
                func = getattr(self, cmd)
            except AttributeError:
                self._sout.write('No such command: {}\n'.format(cmd))
            else:
                doc = func.__doc__ if func.__doc__ else ''
                doc_firstline = doc.split('\n', maxsplit=1)[0]
                arg_list = ' '.join(
                    p for p in inspect.signature(func).parameters)
                self._sout.write(
                    template.format(
                        cmd_name=cmd[len(self._cmd_prefix):],
                        arg_list=arg_list,
                        cmd_arg_sep=' ' if arg_list else '',
                        doc=doc,
                        doc_firstline=doc_firstline
                    ) + '\n'
                )

        if not cmd_names:
            cmds = sorted(
                c.method_name for c in self._filter_cmds(with_alts=False)
            )
            self._sout.write('Available Commands are:\n\n')
            for cmd in cmds:
                _h(cmd, self.help_short_template)
        else:
            for cmd in cmd_names:
                _h(self._cmd_prefix + cmd, self.help_template)
994642
def show_help(self):
        
        output = [
            'Usage %s subcommand [options] [args]' % self.prog_name,
            '',
            'Available commands:',
            '',
        ]
        for cmd in self.get_commands():
            output.append('  %s' % cmd)
        output += ['', '']
        self.stdout.write(u'\n'.join(output))
993512
def cmd_exec(self, cmd):
        

        if not cmd:
            return
        ns = self.cmd_namespace
        import copy
        rval = True
        nscopy = copy.copy(ns)
        try:
            r = eval(cmd, ns)
            if isinstance(r, SystemObject) and not r.system:
                r.setup_system(self)
            if callable(r):
                r = r()
                cmd += "()"
            self.logger.info("Eval: %s", cmd)
            self.logger.info("Result: %s", r)
        except SyntaxError:
            r = {}
            try:
                exec (cmd, ns)
                self.logger.info("Exec: %s", cmd)
            except ExitException:
                raise
            except Exception as e:
                self.logger.info("Failed to exec cmd %s: %s.", cmd, e)
                rval = False
            for key, value in list(ns.items()):
                if key not in nscopy or not value is nscopy[key]:
                    if key in self.namespace:
                        del self.namespace[key]
                    self.namespace[key] = value
                    r[key] = value
            self.logger.info("Set items in namespace: %s", r)
        except ExitException:
            raise
        except Exception as e:
            self.logger.info("Failed to eval cmd %s: %s", cmd, e)
            return False

        return rval
1179574
def cmd_namespace(self):
        
        import automate
        ns = dict(list(automate.__dict__.items()) + list(self.namespace.items()))
        return ns
1047168
@Route(method = POST, uri = "/command/{name}")
    public Result command(@Parameter("name") String name, @Body String args) {
        CommandResult result = shellSession.exec(name + " " + args);

        if (result.isEmpty()) {
            return ok();
        }

        return ok(result.toString());
    }
453327
def make_command(self, ctx, name, info):

        

        @self.command()
        @click.option("--debug/--no-debug", default=False, help="Show debug information")
        @doc(info.get("description"))
        def func(*args, **kwargs):
            if "debug" in kwargs:
                del kwargs["debug"]
            fn = getattr(ctx.widget, name)
            result = fn(*args, **kwargs)
            click.echo("%s: %s> %s" % (ctx.params["host"],name,result))
            ctx.conn.close()

        ctx.info_name = "%s %s" % (ctx.info_name , ctx.params["host"])

        for a in info.get("arguments",[]):
            deco = click.argument(*a["args"], **a["kwargs"])
            func = deco(func)
        for o in info.get("options",[]):
            deco = click.option(*o["args"], **o["kwargs"])
            func = deco(func)

        return func
828673
def command_name(app_name, command, help_text):
    
    command = clr.stringc(command, "cyan")
    help = clr.stringc("--help", "green")

    return "{0} {1} {2}\n{3}\n\n".format(app_name, command,
                                         help, help_text)
411804
def cmd_help(self, *args):
        
        if len(args) > 0:
            cmdname = args[0].lower()
            try:
                method = getattr(self, "cmd_" + cmdname)
                doc = method.__doc__
                if doc is None:
                    self.log("Sorry, no documentation found for '%s'" % (
                        cmdname))
                else:
                    self.log("%s: %s" % (cmdname, doc))
            except AttributeError:
                self.log("No such command '%s'; type help for general help." % (
                    cmdname))
        else:
            res = []
            for attrname in dir(self):
                if attrname.startswith('cmd_'):
                    method = getattr(self, attrname)
                    doc = method.__doc__
                    cmdname = attrname[4:]
                    if doc is None:
                        doc = "no documentation"
                    res.append("%s: %s" % (cmdname, doc))
            self.log('\n'.join(res))
360552
def print_help(self):
        

        print('\n  %s %s' % (self._title or self._name, self._version or ''))

        if self._usage:
            print('\n  %s' % self._usage)
        else:
            cmd = self._name
            if hasattr(self, '_parent') and isinstance(self._parent, Command):
                cmd = '%s %s' % (self._parent._name, cmd)

            if self._command_list:
                usage = 'Usage: %s <command> [option]' % cmd
            else:
                usage = 'Usage: %s [option]' % cmd

            pos = ' '.join(['<%s>' % name for name in self._positional_list])
            print('\n  %s %s' % (usage, pos))

        arglen = max(len(o.name) for o in self._option_list)
        arglen += 2

        self.print_title('\n  Options:\n')
        for o in self._option_list:
            print('    %s %s' % (_pad(o.name, arglen), o.description or ''))
        print('')

        if self._command_list:
            self.print_title('  Commands:\n')
            for cmd in self._command_list:
                if isinstance(cmd, Command):
                    name = _pad(cmd._name, arglen)
                    desc = cmd._description or ''
                    print('    %s %s' % (_pad(name, arglen), desc))

            print('')

        if self._help_footer:
            print(self._help_footer)
            print('')

        return self
150080
def show(name):
    '''
    
    '''
    ret = {}
    ret['enabled'] = False
    ret['disabled'] = True
    ret['running'] = False
    ret['service_path'] = None
    ret['autostart'] = False
    ret['command_path'] = None

    ret['available'] = available(name)
    if not ret['available']:
        return ret

    ret['enabled'] = enabled(name)
    ret['disabled'] = not ret['enabled']
    ret['running'] = status(name)
    ret['autostart'] = status_autostart(name)
    ret['service_path'] = _get_svc_path(name)[0]
    if ret['service_path']:
        ret['command_path'] = os.path.join(ret['service_path'], 'run')

    # XXX provide info about alias ?

    return ret
401280
def _doCommandCompletion(self):
                
        prefix =  ''.join(self.inputBuffer).strip().upper()
        matches = self.completion.keys(prefix)
        matchLen = len(matches)        
        if matchLen == 0 and prefix[-1] == '=':
            try:                
                command = prefix[:-1]
            except KeyError:
                pass                        
            else:
                self.__printCommandSyntax(command)
        elif matchLen > 0:                        
            if matchLen == 1:
                if matches[0] == prefix:
                    # User has already entered command - show command syntax
                    self.__printCommandSyntax(prefix)
                else:
                    # Complete only possible command
                    self.inputBuffer = list(matches[0])
                    self.cursorPos = len(self.inputBuffer)
                    self._refreshInputPrompt(len(self.inputBuffer))
                return
            else:
                commonPrefix = self.completion.longestCommonPrefix(''.join(self.inputBuffer))
                self.inputBuffer = list(commonPrefix)
                self.cursorPos = len(self.inputBuffer)
                if matchLen > 20:
                    matches = matches[:20]
                    matches.append('... ({0} more)'.format(matchLen - 20))
            sys.stdout.write('\n')
            for match in matches:
                sys.stdout.write(' {0} '.format(match))
            sys.stdout.write('\n')
            sys.stdout.flush()
            self._refreshInputPrompt(len(self.inputBuffer))
469925
private static void printUsage(String cmd) {
    if ("-refreshServiceAcl".equals(cmd)) {
      System.err.println("Usage: java MRAdmin" + " [-refreshServiceAcl]");
    } else if ("-refreshQueueAcls".equals(cmd)) {
      System.err.println("Usage: java MRAdmin" + " [-refreshQueueAcls]");
    } else if ("-refreshNodes".equals(cmd)) {
      System.err.println("Usage: java MRAdmin" + " [-refreshNodes]");
    } else {
      System.err.println("Usage: java MRAdmin");
      System.err.println("           [-refreshServiceAcl]");
      System.err.println("           [-refreshQueueAcls]");
      System.err.println("           [-refreshNodes]");
      System.err.println("           [-help [cmd]]");
      System.err.println();
      ToolRunner.printGenericCommandUsage(System.err);
    }
  }
1231803
def get_ns_commands(self, cmd_name):
        
        namespace, command = _split_ns_command(cmd_name)
        if not namespace:
            # Name space not given, look for the commands
            spaces = self.__find_command_ns(command)
            if not spaces:
                # Unknown command
                raise ValueError("Unknown command {0}".format(command))
            else:
                # Return a sorted list of tuples
                return sorted((namespace, command) for namespace in spaces)

        # Single match
        return [(namespace, command)]
688511
def add_command(self, handler, name=None):
        
        if name is None:
            name = docstring_to_subcommand(handler.__doc__)

        # TODO: Prevent overwriting 'help'?
        self._commands[name] = handler
1239618
def _do_print(self, cmd, args):
        
        name = args[0].strip()
        if not name:
            self.stderr.write('TODO: Display names of inspectable objects.\n')
            return
        try:
            code = textwrap.dedent(r'''
                    self.stdout.write(name + ':\n' + textwrap.indent(pprint.pformat({}), '    ') + '\n')
                    ''').format(name).strip()
            eval(code, globals(), locals())
        except NameError:
            self.stderr.write("p: name '{}' is not defined\n".format(name))
        self.stdout.flush()
1149925
def command_packet(cmd):
    
    return message('Command',
                   Container(string_length=len(cmd),
                             string=bytes(cmd, ENCODING)),
                   len(cmd) + 2)