console.dir(COMMANDS.sync) console.dir(require.resolve('jsr-constants')); 
Validate whether a command is known.

@param cmd The command name (lowercase).
@param args The command arguments, must be an array.
@param info The server information.
422417
function command(cmd, args, info) {
  var map = info.commands || Constants.MAP
    , def = map[cmd]
    , sub;

  // support command exec handlers that
  // encapsulate the definition
  if(def && def.definition !== undefined) {
    def = def.definition;
  }

  // top-level command
  if(def === undefined) {
    throw new UnknownCommand(cmd);
  }

  // made it this far, check subcommands
  // for commands that require a subcommand
  if(Constants.SUBCOMMAND[cmd] && args.length > 0) {
    sub = Constants.SUBCOMMAND[cmd][args[0]];
    if(!sub) {
      if(cmd === Constants.MAP.client.name) {
        throw ClientSyntax;
      }
      throw UnknownSubcommand;
    }
    // mutate the sub response to include
    // the subcommand as a primary command
    // and the remaining arguments, callers
    // can use this to locate a subcommand
    // execution method
    sub = {def: sub, cmd: args[0], args: args.slice(1)};
  }

  return {cmd: cmd, args: args, def: def, sub: sub};
}
253452
public static void main(final String[] args) {
		EnvironmentInformation.logEnvironmentInfo(LOG, "Command Line Client", args);

		// 1. find the configuration directory
		final String configurationDirectory = getConfigurationDirectoryFromEnv();

		// 2. load the global configuration
		final Configuration configuration = GlobalConfiguration.loadConfiguration(configurationDirectory);

		// 3. load the custom command lines
		final List<CustomCommandLine<?>> customCommandLines = loadCustomCommandLines(
			configuration,
			configurationDirectory);

		try {
			final CliFrontend cli = new CliFrontend(
				configuration,
				customCommandLines);

			SecurityUtils.install(new SecurityConfiguration(cli.configuration));
			int retCode = SecurityUtils.getInstalledContext()
					.runSecured(() -> cli.parseParameters(args));
			System.exit(retCode);
		}
		catch (Throwable t) {
			final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
			LOG.error("Fatal error while running command line interface.", strippedThrowable);
			strippedThrowable.printStackTrace();
			System.exit(31);
		}
	}
1072608
public void help(String command) {

        if ("*".equalsIgnoreCase(command)) {
            m_shell.help(null);
        } else if ("help".equalsIgnoreCase(command)) {
            help();
        } else {
            m_shell.help(command);
        }
    }
784158
public void command(String... args)
    {
        try
        {
            setArgs(args);
        }
        catch (CmdArgsException ex)
        {
            ex.printStackTrace();
            Logger logger = Logger.getLogger(CmdArgs.class.getName());
            logger.log(Level.SEVERE, Arrays.toString(args));
            logger.log(Level.SEVERE, ex.getMessage(), ex);
            logger.log(Level.SEVERE, ex.usage());
            System.exit(-1);
        }
    }
1327147
function deleteCommandOnCmdEditor (config) {

	var commands = config.commands || {};
	var command_names = Object.keys(commands);
	command_names.unshift('<< Cancel');

	var promise = inquirer.prompt([{
		type: 'list',
		name: 'cmdName',
		message: 'Choose the command you want to delete',
		choices: command_names
	}]);

	return promise.then(function (answer) {

		if (answer.cmdName == '<< Cancel') {
			return false;
		}

		delete config.commands[answer.cmdName];

		// Done
		console.log(colors.bold.green('\n\nThis command has been deleted: ' + answer.cmdName));

		// Save to the commands file
		console.log('\nWriting to ' + process.cwd() + '/' + COMMANDS_FILENAME);
		fs.writeFileSync(COMMANDS_FILENAME, JSON.stringify(config.commands));
		console.log('Writing has been completed.\n\n');

		return true;

	});

}
209214
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var start
    , end;

  if(args.length !== 1 && args.length !== 3) {
    throw new CommandArgLength(cmd);
  }

  if(args.length > 1) {
    start = parseInt('' + args[1]);
    if(isNaN(start)) throw IntegerRange;
    args[1] = start;
    end = parseInt('' + args[2]);
    if(isNaN(end)) throw IntegerRange;
    args[2] = end;
  }
}
282612
@Override
    public void command(String... args)
    {
        addArgument(File.class, "xml-config-file-path");
        super.command(args);
        configFile = getArgument("xml-config-file-path");
        readConfig();
        if (watch)
        {
            Thread thread = new Thread(this, configFile+" watcher");
            thread.start();
        }
    }
1264329
function cmd(method, params, callback, streamResults, returnRawData){

        var results = [];

        async.each(instances, function(instance, eachCallback){

            var itemFinished = function(error, result, data){

                var returnObj = {
                    error: error,
                    response: (result || {}).result,
                    instance: instance
                };
                if (returnRawData) returnObj.data = data;
                if (streamResults) callback(returnObj);
                else results.push(returnObj);
                eachCallback();
                itemFinished = function(){};
            };

            var requestJson = JSON.stringify({
                method: method,
                params: params,
                id: Date.now() + Math.floor(Math.random() * 10)
            });

            performHttpRequest(instance, requestJson, function(error, result, data){
                itemFinished(error, result, data);
            });


        }, function(){
            if (!streamResults){
                callback(results);
            }
        });

    }
516430
public SyncToolConfig processCommandLine(String[] args) {
        SyncToolConfig config = null;
        try {
            config = processConfigFileOptions(args);
        } catch (ParseException e) {
            printHelp(e.getMessage());
        }
        return config;
    }
1360741
function (cmd) {
    var cmdName = dotty.get(cmd, this.definitions.command.name);

    if (!cmdName) {
      var err = new Error('command has no command name in ' + this.definitions.command.name);
      debug(err);
      throw err;
    }

    var version = 0;
    if (!!this.definitions.command.version) {
      version = dotty.get(cmd, this.definitions.command.version);
    }

    var command = this.getCommand(cmdName, version);
    if (!command) {
      var aggregateId = dotty.get(cmd, this.definitions.command.aggregateId);
      var aggregateName = this.name;
      var contextName = this.context.name;

      return [{
        context: contextName,
        aggregate: aggregateName,
        aggregateId: aggregateId
      }];
    }

    return command.getLoadInfo(cmd);
  }
960811
function showCommandsOnCmdEditor (config) {

	console.log(colors.bold('\nAvailable Commands for ' + config.deviceName + ':\n'));

	// Iterate the each commands
	var commands = config.commands || {};
	if (Object.keys(commands).length == 0) {
		console.log ('\nThere is no command.');
	} else {
		for (var name in commands) {
			var desc = commands[name].description || '';
			console.log(colors.bold('\n' + name + '') + '\n  ' + desc + '\n');

			// Iterate the each arguments
			var args = commands[name].args || {};
			if (Object.keys(args).length == 0) {
				console.log ('\tThe arguments of this command are not defined');
			} else {
				for (var arg_name in args) {
					var arg_spec = args[arg_name] || '';
					console.log('\t* ' + arg_name + ' - ' + arg_spec);
				}
			}

		}
	}

	console.log('\n');

	// Done
	return new Promise(function (resolve, reject) {
		resolve();
	});

}
1002159
public void addChild(Command cmd)
	{
		if (cmd != null)
		{
			cmd.setContext(this);
			commands.add(cmd);
		}
	}
259931
function addValidCommands(command) {
		var result = false
		if (command && commands.indexOf(command) != -1) {
			result = true
			commandQueue.push(command)
		}
		return result
	}
80812
public boolean containsActionCommand(String commandId) {
        
        if (commandMap.containsKey(commandId)) {
            return true;
        }
        
        if (parent != null) {
            return parent.containsActionCommand(commandId);
        }
        
        return false;
        
    }
1047515
public void parseAndEmit(String[] args) {
    	logger.finest("Checking command line arguments.");
        if (args.length != 2) {
        	final String version = new Version().getVersion();
        	logger.info("jADT version " + version + ".");
        	logger.info("Not enough arguments provided to jADT");
        	logger.info("usage: java sfdc.adt.JADT [source file or directory with .jadt files] [output directory]");
            throw new IllegalArgumentException("\njADT version " + version + "\nusage: java sfdc.adt.JADT [source file or directory with .jadt files] [output directory]");
        }
        
        final String srcPath = args[0];
        final String destDirName = args[1];

        parseAndEmit(srcPath, destDirName);        
    }
1362181
function auth(cmd, args, info) {
  var pass = args[0];
  if(pass instanceof Buffer) {
    pass = pass.toString();
  }
  if(!info.conf.requirepass) {
    throw AuthNotSet;
  }else if(pass !== info.conf.requirepass) {
    throw InvalidPassword;
  }
  return true;
}
110102
function Command(args) {
  if (false === (this instanceof Command)) throw new Error('new operator required');
  if (typeof args == 'function') { // shorthand for function command
    args = {type: 'Function', contents: args};
  }
  if (args instanceof Procedure) { // shorthand for Procedure command
    args = {type: 'Procedure', contents: args};
  }
  args = args || {};
  var i;
  var unusedProperties = getInvalidProperties(args,
    ['name', 'description', 'type', 'contents', 'scope', 'timeout', 'theme', 'icon', 'bucket', 'presentationMode','location','images']);
  var errorList = [];
  for (i = 0; i < unusedProperties.length; i++) errorList.push('invalid property: ' + unusedProperties[i]);
  if (errorList.length > 1) throw new Error('error creating Command: multiple errors');
  if (errorList.length) throw new Error('error creating Command: ' + errorList[0]);
  for (i in args) this[i] = args[i];
  this.name = this.name || "a command"; // name is optional
  if ('string' != typeof this.name) throw new Error('name must be string');
  if ('undefined' == typeof this.description) this.description = this.name + ' Command';
  if ('undefined' == typeof this.type) this.type = 'Stub';
  if (!contains(Command.getTypes(), this.type)) throw new Error('Invalid command type: ' + this.type);
  switch (this.type) {
    case 'Stub':
      break;
    case 'Menu':
      if (!(this.contents instanceof Array)) throw new Error('contents must be array of menu items');
      if (!this.contents.length) throw new Error('contents must be array of menu items');
      for (i in this.contents) {
        if (this.contents.hasOwnProperty(i))
          if (typeof this.contents[i] != 'string' && !(this.contents[i] instanceof Command))
            throw new Error('contents must be array of menu items');
      }
      break;
    case 'Presentation':
      if (!(this.contents instanceof Presentation)) throw new Error('contents must be a Presentation');
      this.presentationMode = this.presentationMode || 'View';
      if (!contains(Command.getPresentationModes(), this.presentationMode)) throw new Error('Invalid presentationMode: ' + this.presentationMode);
      //['View', 'Edit', 'List']
      break;
    case 'Function':
      if (typeof this.contents != 'function') throw new Error('contents must be a Function');
      break;
    case 'Procedure':
      if (!(this.contents instanceof Procedure)) throw new Error('contents must be a Procedure');
      break;
    default:
      throw new TypeError();
  }
  if ('undefined' != typeof this.scope)
    if (!((this.scope instanceof Model) || (this.scope instanceof List)))
      throw new Error('optional scope property must be Model or List');
  if ('undefined' != typeof this.timeout)
    if (typeof this.timeout != 'number') throw new Error('timeout must be a Number');
  if ('undefined' != typeof this.timeout)
    if (typeof this.timeout != 'number') throw new Error('timeout must be a Number');
  if ('undefined' != typeof this.theme) {
    if ('string' != typeof this.theme) throw new Error('invalid theme');
    if (!contains(['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'], this.theme))
      throw new Error('invalid theme');
  }
  if ('undefined' != typeof this.icon) {
    if ('string' != typeof this.icon) throw new Error('invalid icon');
    if (!contains(['fa', 'glyphicon'], this.icon.split('-')[0]) || !this.icon.split('-')[1])
      throw new Error('invalid icon');
  }

  // Validations done
  this._eventListeners = [];
}