Declare a method as being related to the given command object.

        @param commandObject: a L{Command} subclass.
779701
def expose(self, commandObject):
        
        thunk = super(_AMPExposer, self).expose(commandObject.commandName)
        def thunkplus(function):
            result = thunk(function)
            result.command = commandObject
            return result
        return thunkplus
520956
public void addCommand(String key, Command<? super T> handler) {
    commands.put(key, handler);
  }
1366831
protected void buildCommandLine(final StringBuilder out, final List<NodeOc> depth, final List<NodeOc> line,
            final String value)
    {
        for (int n = 0; n < line.size(); n++)
        {
            if (depth.size() <= n)
            {
                /*
                 * This is a new command
                 */
                depth.add(line.get(n));
                /*
                 * an empty keyword means a positional parameter
                 */
                if (line.get(n).key.length() > 0)
                    out.append("--" + line.get(n).key);
                /*
                 * if the depth so far is shorter than the namespace then it is
                 * necessary to start a group
                 */
                if (n < line.size() - 1)
                    out.append(OPEN_GROUP);
            } else if (depth.get(n).key.equalsIgnoreCase(line.get(n).key))
            {
                /*
                 * This is a subsequent command for the same namespace at this
                 * level. Check the occurrence to see if a new multiple group )(
                 * should be started. If the occurrence is the same then the
                 * subsequent namespace will make it unique and this specific
                 * node in the namespace can be safely ignored. In essence we
                 * are within a sub-structure and only change instance
                 * variables.
                 */
                if (depth.get(n).occurrance == line.get(n).occurrance)
                    continue;
                /*
                 * A new occurrence of the same namespace node. So we close off
                 * deeper groups.
                 */
                for (int d = depth.size() - 1; d > n; d--)
                {
                    depth.remove(d);
                    out.append(CLOSE_GROUP);
                }
                depth.get(n).occurrance = line.get(n).occurrance;
                if (n < line.size() - 1)
                    out.append(OPEN_GROUP);
                continue;
            } else
            {
                for (int d = depth.size() - 1; d > n; d--)
                {
                    depth.remove(d);
                    out.append(CLOSE_GROUP);
                }
                depth.get(n).key = line.get(n).key;
                depth.get(n).occurrance = line.get(n).occurrance;
                /*
                 * an empty keyword means a positional parameter
                 */
                if (line.get(n).key.length() > 0)
                    out.append("--" + line.get(n).key);
                if (n < line.size() - 1)
                    out.append(OPEN_GROUP);
                continue;
            }
        }
        /*
         * booleans have no value
         */
        if (value.length() > 0)
            out.append(quote(value));
    }
556338
function _registerCommands(basedir, globalObject) {
    var commandsDir = path.resolve(basedir, "commands");

    var files;
    try {
        files = Utils.getAllFilePathsUnderDirectory(commandsDir);
        LOG.info("Found the following potential command files: {}", files);
    }
    catch (e) {
        LOG.error("Unable to register commands from the base directory '{}'. Error: {}", commandsDir, e);
        return;
    }

    var commands = [];
    for (var i = 0; i < files.length; i++) {
        var filePath = files[i];
        if (filePath.lastIndexOf(".js") !== filePath.length - 3) {
            LOG.info("File {} doesn't appear to be a JS module. Ignoring.", filePath);
            continue;
        }

        var module = require(filePath);

        if (!module.triggers || !module.handler) {
            LOG.warn("Found a module at {} but it doesn't appear to be a command handler. Ignoring.", filePath);
            continue;
        }

        if (typeof module.init === "function") {
            module.init(globalObject);
        }

        commands.push(module);
        LOG.info("Registered command from file {}", filePath);
    }

    return commands;
}
1026228
private Consumer wrapVoidMethod(Method method) {
    return c -> {
      try {
        method.invoke(this, c);
      } catch (InvocationTargetException e) {
        throw new CommandException(e);
      } catch (IllegalAccessException e) {
        throw new AssertionError(e);
      }
    };
  }
437890
def redefine_command_block(obj, command)
      object_methods(obj)[command.name] ||= begin
        obj.method(command.name)
      rescue NameError
        raise Error, "No method exists to redefine command '#{command.name}'."
      end
      lambda {|*args|
        Scientist.analyze(obj, command, args) {|args|
          Scientist.object_methods(obj)[command.name].call(*args)
        }
      }
    end
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);
}
1177779
public void addCommand(String name, Object object, String... aliases) {
        JCommander jc = new JCommander(options);
        jc.addObject(object);
        jc.createDescriptions();
        jc.setProgramName(name, aliases);
        ProgramName progName = jc.programName;
        commands.put(progName, jc);

    /*
    * Register aliases
    */
        //register command name as an alias of itself for reverse lookup
        //Note: Name clash check is intentionally omitted to resemble the
        //     original behaviour of clashing commands.
        //     Aliases are, however, are strictly checked for name clashes.
        aliasMap.put(new StringKey(name), progName);
        for (String a : aliases) {
            IKey alias = new StringKey(a);
            //omit pointless aliases to avoid name clash exception
            if (!alias.equals(name)) {
                ProgramName mappedName = aliasMap.get(alias);
                if (mappedName != null && !mappedName.equals(progName)) {
                    throw new ParameterException("Cannot set alias " + alias
                            + " for " + name
                            + " command because it has already been defined for "
                            + mappedName.name + " command");
                }
                aliasMap.put(alias, progName);
            }
        }
    }
801514
def run(klass, method)
      # Get the command info for this method on this klass
      command_info_module = klass::CommandInfo.const_get(camelize(method))

      # If seeking help for this command with --help or -h
      if seeking_command_help?(@current_args)
        puts "\nPurpose: #{command_description(command_info_module)}\n"

        # respond with command-specific help
        respond_with_command_help(command_info_module)
        return
      end

      # get the valid arguments defined for this comand
      valid_args = command_valid_args(command_info_module)

      if !valid_args?(valid_args)
        handle_invalid_args(command_info_module)
        return
      end

      klass.new(@current_args.dup).send(method)
    end
139140
@CommandDescList({
		@CommandDesc(longName = "style",
				description = "get the current citation style",
				command = ShellGetStyleCommand.class),
		@CommandDesc(longName = "locale",
				description = "get the current citation locale",
				command = ShellGetLocaleCommand.class),
		@CommandDesc(longName = "format",
				description = "get the current output format",
				command = ShellGetFormatCommand.class),
	})
	public void setSubcommand(AbstractCSLToolCommand subcommand) {
		this.subcommand = subcommand;
	}
470333
function CommandDispatcher (tree, definition, commandBumper) {
  if (!tree || !_.isObject(tree) || !_.isFunction(tree.getCommandHandler)) {
    var err = new Error('Please pass a valid tree!');
    debug(err);
    throw err;
  }

  if (!definition || !_.isObject(definition)) {
    var err = new Error('Please pass a valid command definition!');
    debug(err);
    throw err;
  }

  this.tree = tree;
  this.definition = definition;

  this.commandBumper = commandBumper;
}
1064486
public void setClassOfObject(Class c)
    {
        m_Class = c;
        isAbstract = Modifier.isAbstract(m_Class.getModifiers());
        // TODO : Shouldn't the HashMap in DescriptorRepository be updated as well?
    }
59788
public void queryService(List<StringCommand> commands, final QueryServiceCallback cb, Object context){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.QueryService);

        List<QueryCommand> cs = new ArrayList<QueryCommand>();
        for(StringCommand c : commands){
            cs.add(c.getStringCommand());
        }

        QueryServiceProtocol p = new QueryServiceProtocol(cs);

        ProtocolCallback pcb = new ProtocolCallback(){

            @Override
            public void call(boolean result, Response response,
                    ErrorCode error, Object ctx) {
                List<ModelServiceInstance> rsp = null;
                if(response != null){
                    rsp = ((QueryServiceResponse) response).getInstances();
                }
                cb.call(result, rsp, error, ctx);
            }

        };

        connection.submitCallbackRequest(header, p, pcb, context);
    }
714259
function addSignatory (commandOptions, { accountId, publicKey }) {
  return command(
    commandOptions,
    txHelper.addCommand(
      txHelper.emptyTransaction(),
      'addSignatory',
      {
        accountId,
        publicKey
      }
    )
  )
}
1062516
function grantPermission (commandOptions, { accountId, grantablePermissionName }) {
  return command(
    commandOptions,
    txHelper.addCommand(
      txHelper.emptyTransaction(),
      'grantPermission',
      {
        accountId,
        grantablePermissionName
      }
    )
  )
}
494973
public static List<CommandDetail> parse(List<?> commandOutput) {
        LettuceAssert.notNull(commandOutput, "CommandOutput must not be null");

        List<CommandDetail> result = new ArrayList<>();

        for (Object o : commandOutput) {
            if (!(o instanceof Collection<?>)) {
                continue;
            }

            Collection<?> collection = (Collection<?>) o;
            if (collection.size() != COMMAND_INFO_SIZE) {
                continue;
            }

            CommandDetail commandDetail = parseCommandDetail(collection);
            result.add(commandDetail);
        }

        return Collections.unmodifiableList(result);
    }
1247750
static Action create(Runnable command)
    {
        Objects.requireNonNull(command, "The command may not be null");
        return new AbstractAction()
        {
            /**
             * Serial UID
             */
            private static final long serialVersionUID = 8693271079128413874L;

            @Override
            public void actionPerformed(ActionEvent e)
            {
                command.run();
            }
        };
    }