Delegate a subcommand to a method declared on the exec instance.
191140
function delegate(req, res) {
  var cmd = req.info.command
    , method;

  if(!cmd.sub) {
    throw new Error('attempt to delegate with no subcommand info');
  }

  method = req.exec[cmd.sub.cmd];

  // subcommand is declared but the command exec handler
  // has not declared the method and is attempting to delegate
  // we treat this as unknown subcommand which allows partial
  // subcommand exec handlers that may call delegate but only
  // implement a subset of the declared subcommands
  if(typeof method !== 'function') {
    return res.send(StoreError.UnknownSubcommand);
  }

  // rewrite the cmd/args
  req.cmd = cmd.sub.cmd;
  req.args = cmd.sub.args;
  method.call(this, req, res);
}
1201717
def run_command(self, codeobj):
        """"""
        try:
            value, stdout = yield from self.attempt_exec(codeobj, self.namespace)
        except Exception:
            yield from self.send_exception()
            return
        else:
            yield from self.send_output(value, stdout)
623795
def invoke(command, params={})
      command_string = compile_command(command, params)
      output_command(command_string)
      execute(command_string, params)
    end
768278
function _handleCommandRegistered(event, command) {
        var commandId   = command.getID(),
            defaults    = KeyboardPrefs[commandId];

        if (defaults) {
            addBinding(commandId, defaults);
        }
    }
115476
def method_missing(method, *args, &block)
      if @queue.respond_to?(method)
        proc = @queue.scopes[method]
        instance_exec *args, &proc
      end
    end
1195597
def _subprocess_method(self, command):
        
        p = subprocess.Popen([self._ipmitool_path] + self.args + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        self.output, self.error = p.communicate()
        self.status = p.returncode
924552
def exec_cmd(self, command, **kwargs):
        """"""
        self._is_allowed_command(command)
        self._check_command_parameters(**kwargs)

        if command == 'load':
            kwargs['command'] = command
            self._check_exclusive_parameters(**kwargs)
            requests_params = self._handle_requests_params(kwargs)
            session = self._meta_data['bigip']._meta_data['icr_session']
            try:

                session.post(
                    self._meta_data['uri'], json=kwargs, **requests_params)

            except HTTPError as err:
                if err.response.status_code != 502:
                    raise
                return

        else:
            return self._exec_cmd(command, **kwargs)
289266
def add_subcommands(parser, commands):
    ""
    subps = parser.add_subparsers()
    for cmd, cls in commands:
        subp = subps.add_parser(cmd, help=cls.__doc__)
        add_args = getattr(cls, 'add_arguments', None)
        if add_args:
            add_args(subp)
        handler = getattr(cls, 'handle', None)
        if handler:
            subp.set_defaults(handler=handler)
994491
def _make_command_method(cls, command_name):
        
        def func(self, *args, **kwargs):
            return self._call_command(command_name, *args, **kwargs)
        return func
1017927
private void attachCommandExecutor() {
        if (this.commandExecutor instanceof GuardedActionCommandExecutor) {
            GuardedActionCommandExecutor dynamicHandler = (GuardedActionCommandExecutor)commandExecutor;
            setEnabled(dynamicHandler.isEnabled());
            subscribeToGuardedCommandDelegate();
        }
        else {
            setEnabled(true);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Command executor '" + this.commandExecutor + "' attached.");
        }
    }
106643
def call(self, command, *args):
        

        if not command:
            return

        # Look for local methods first
        try:
            res = self.registered[command]['function'](self, *args)
            return Response('local', res, None)

        # Method not found, try remote
        except KeyError:

            # Execute remote command
            res, err = self.client.call(command, *args)
            return Response('remote', res, err, self.client.is_multi())

        # Local exception
        except Exception as e:
            return Response('local', res, str(e))
214552
def render_subcommand(args):
    """"""
    if args.subcommand == 'delete':
        return 'delete ' + args.delete_subcommand

    if args.subcommand in ('wal-prefetch', 'wal-push', 'wal-fetch'):
        return None

    return args.subcommand
200003
def exec_command(
        client, container, command, interactive=True, stdout=None, stderr=None, stdin=None):
    
    exec_id = exec_create(client, container, command, interactive=interactive)

    operation = ExecOperation(client, exec_id,
                              interactive=interactive, stdout=stdout, stderr=stderr, stdin=stdin)
    PseudoTerminal(client, operation).start()
5446
def on_command_call(*args)
    if args.last && :args == args.last[0]
      args_add = args.pop
      call = on_call(*args)
      on_method_add_arg(call, args_add)
    else
      super
    end
  end
15935
def delegate(self, fn, *args, **kwargs):
        """"""
        callback = functools.partial(fn, *args, **kwargs)
        coro = self.loop.run_in_executor(self.subexecutor, callback)
        return asyncio.ensure_future(coro)
1185216
public static void executeCommand(String[] args) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        args = CoordinatorAdminUtils.copyArrayCutFirst(args);
        if(subCmd.equals("get")) {
            SubCommandGet.executeCommand(args);
        } else if(subCmd.equals("put")) {
            SubCommandPut.executeCommand(args);
        } else if(subCmd.equals("delete")) {
            SubCommandDelete.executeCommand(args);
        } else {
            args = CoordinatorAdminUtils.copyArrayAddFirst(args, subCmd);
            executeHelp(args, System.out);
        }
    }
1113109
def call(self, cmd, **kwargs):
        """"""
        if isinstance(cmd, basestring):
            cmd = cmd.split()
        self.log.info('Running %s', cmd)
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, **kwargs)
        out, err = p.communicate()
        if out:
            self.log.info(out)
        if err:
            if p.returncode == 0:
                self.log.info(err)
            else:
                self.log.error(err)
        if p.returncode != 0:
            self.log.error('returncode = %d' % p.returncode)
            raise Exception
        return out, err, p.returncode