Command decorator
191917
def command(function):
    """"""
    def decorate(*args, **kwargs):
        exit_code = 1
        try:
            exit_code = function(*args, **kwargs)
        except Exception as e:
            if str(e):
                click.secho('Error: ' + str(e), fg='red')
        finally:
            return exit_code
    return decorate
561904
def command(*args, **kwargs):
    
    def decorator(f):
        if 'description' not in kwargs:
            kwargs['description'] = f.__doc__
        if 'parents' in kwargs:
            if not hasattr(f, '_argnames'):  # pragma: no cover
                f._argnames = []
            for p in kwargs['parents']:
                f._argnames += p._argnames if hasattr(p, '_argnames') else []
            kwargs['parents'] = [p.parser for p in kwargs['parents']]
        f.parser = argparse.ArgumentParser(*args, **kwargs)
        f.climax = True
        for arg in getattr(f, '_arguments', []):
            f.parser.add_argument(*arg[0], **arg[1])

        @wraps(f)
        def wrapper(args=None):
            kwargs = f.parser.parse_args(args)
            return f(**vars(kwargs))

        wrapper.func = f
        return wrapper
    return decorator
23546
def command(self, *args, **kwargs):
        
        aliases = kwargs.pop('aliases', None)
        decorator = super(ProfilingCLI, self).command(*args, **kwargs)
        if aliases is None:
            return decorator
        def _decorator(f):
            cmd = decorator(f)
            for alias in aliases:
                self.command_name_aliases[alias] = cmd.name
            return cmd
        return _decorator
1187863
def subcommand_builder(self, command_name, description=None):
        
        def wrapper(decorated):
            subparser = self.subparsers.add_parser(command_name)
            func = decorated(subparser)
            subparser.set_defaults(func=func)
            subparser.description = description or func.__doc__
        return wrapper
72619
def command(func):
    
    # pylint: disable=protected-access,unused-variable
    nargs = numargs(func)
    if nargs > 0:
        raise WrongNumberOfArguments(
            f'Decorated function "{func.__name__}" should have no arguments, it has {nargs}.'
        )
    app = func()
    if app is None:
        raise TypeError(
            'No `App` instance was returned. '
            'In the function decorated with @command, '
            'return the `App` instance so it can be built.'
        )
    if not isinstance(app, App):
        raise TypeError(
            f'Returned value {app} is of type {type(app)}, '
            'it needs to be a bowtie.App instance.'
        )

    @click.group(options_metavar='[--help]')
    def cmd():
        """Bowtie CLI to help build and run your app."""

    @cmd.command(add_help_option=False)
    def build():
        """Write the app, downloads the packages, and bundles it with Webpack."""
        app._build()

    @cmd.command(add_help_option=False)
    @click.option('--host', '-h', default='0.0.0.0', type=str)
    @click.option('--port', '-p', default=9991, type=int)
    def run(host, port):
        """Build the app and serve it."""
        app._build()
        app._serve(host, port)

    @cmd.command(add_help_option=True)
    @click.option('--host', '-h', default='0.0.0.0', type=str)
    @click.option('--port', '-p', default=9991, type=int)
    def serve(host, port):
        """Serve the Bowtie app."""
        app._serve(host, port)

    @cmd.command(context_settings=dict(ignore_unknown_options=True),
                 add_help_option=False)
    @click.argument('extra', nargs=-1, type=click.UNPROCESSED)
    def dev(extra):
        """Recompile the app for development."""
        line = (_WEBPACK, '--config', 'webpack.dev.js') + extra
        call(line, cwd=app._build_dir)

    @cmd.command(context_settings=dict(ignore_unknown_options=True),
                 add_help_option=False)
    @click.argument('extra', nargs=-1, type=click.UNPROCESSED)
    def prod(extra):
        """Recompile the app for production."""
        line = (_WEBPACK, '--config', 'webpack.prod.js', '--progress') + extra
        call(line, cwd=app._build_dir)

    locale = inspect.stack()[1][0].f_locals
    module = locale.get("__name__")

    if module == "__main__":
        try:
            arg = sys.argv[1:]
        except IndexError:
            arg = ('--help',)
        # pylint: disable=too-many-function-args
        sys.exit(cmd(arg))

    return cmd
493980
def command(self, regexp):
        

        def decorator(fn):
            self.add_command(regexp, fn)
            return fn

        return decorator
1188130
def command(self, *args, **kwargs):
        """"""
        if len(args) == 1 and isinstance(args[0], collections.Callable):
            return self._generate_command(args[0])
        else:
            def _command(func):
                return self._generate_command(func, *args, **kwargs)
            return _command
977314
def clean(func):
    
    def wrapper(*args, **kwargs):
        # tuple: output command, path given from command line,
        # path of templ file when you give the payload
        out, given_path, path = func(*args, **kwargs)

        try:
            if not given_path:
                os.remove(path)
        except OSError:
            pass

        return out

    return wrapper
922068
def cmd(self,
            tgt,
            fun,
            arg=(),
            timeout=None,
            tgt_type='glob',
            kwarg=None,
            **kwargs):
        '''
        
        '''
        ssh = self._prep_ssh(
                tgt,
                fun,
                arg,
                timeout,
                tgt_type,
                kwarg,
                **kwargs)
        final = {}
        for ret in ssh.run_iter(jid=kwargs.get('jid', None)):
            final.update(ret)
        return final
467934
function wrapCommand (fn) {
  return (...args) => {
    return fn(...args).catch(err => {
      console.error(chalk.red(err.stack))
      process.exitCode = 1
    })
  }
}
399043
def cmd(
        name,
        fun=None,
        arg=(),
        **kwargs):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'comment': '',
           'result': True}
    if fun is None:
        fun = name
    client = salt.wheel.WheelClient(__opts__)
    low = {'fun': fun,
            'arg': arg,
            'kwargs': kwargs}
    client.cmd_async(low)
    return ret
704723
def repl_command(fxn):
    

    @functools.wraps(fxn)
    def wrapper(self, arglist):
        """Wraps the command method"""
        args = []
        kwargs = {}
        if arglist:
            for arg in shlex.split(arglist):
                if "=" in arg:
                    split = arg.split("=", 1)
                    kwargs[split[0]] = split[1]
                else:
                    args.append(arg)
        return fxn(self, *args, **kwargs)

    return wrapper
423384
def command(self, func):
        
        command = Command(func)
        self._commands[func.__name__] = command
        return func
1363178
def handler(event):
    """"""
    def decorator(fn):
        def apply(cls):
            event.connect(fn, sender=cls)
            return cls

        fn.apply = apply
        return fn
    return decorator
722343
function cleanArgs (cmd) {
  const args = {}
  cmd.options.forEach(o => {
    const key = camelize(o.long.replace(/^--/, ''))
    // if an option is not present and Command has a method with the same name
    // it should not be copied
    if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
      args[key] = cmd[key]
    }
  })
  return args
}
847207
def cmd_func_name(self, command: str) -> str:
        
        target = COMMAND_FUNC_PREFIX + command
        return target if callable(getattr(self, target, None)) else ''
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