Command Line class

@private
@constructor
@class CommandLine
@param {object} commands Commands object to pass
339365
function CommandLine(commands) {
  this.keys = Object.keys(commands);
  this.commands = commands;
  this.args = process.argv.slice(2);
  this.context = this.args[0] || null;
  this.help = {
    before: '',
    after: ''
  }
}
215890
function cmdHelp(command) {
        let ext = '';
        if (command.args && command.args.length > 0) {
            ext = command.args.join(' ');
        }
        if (ext && helpTopics[ext]) {
            const txt = `Help topic for \`${ext}\`\n\n${helpTopics[ext]}` +
                '\n\nIssue the `help` command without any parameters to see all available commands';
            command.reply(txt);

        } else {
            const help = `${getCommandHelps()}\n\n\\* Help topic available.\n\nIssue the \`help\` command with an ` +
                'available help topic as a parameter to read additonal help';
            command.reply(help);
        }
        return Promise.resolve();
    }
345405
function runCommand(command) {
    return new Promise((resolve, reject) => {
        utils.logInfo(`Command: ${command}`);
        childProcess.exec(command, (error, stdout, stderr) => {
            // If exec returns content in stderr, but no error, print it as a warning.
            // If exec returns an error, reject the promise.
            if (error) {
                reject(error);
                return;
            } else if (stderr) {
                utils.logInfo(stderr);
            }
            resolve(stdout);
        });
    });
}
861489
function _executeCommands (showDetails, cmds) {

			if (cmds.length) {

				const cmd = cmds.shift();

				execute(showDetails, cmd.cmd, cmd.options).then((...data) => {

					if (data.length && undefined !== data[0]) {

						if (1 === data.length && "boolean" === typeof data[0]) {

							if (showDetails) {
								(0, console).log(getFormatedTime(), "=>", data[0]);
							}
							else {
								(0, console).log(data[0] ? "1" : "0");
							}

						}
						else if (showDetails) {
							(0, console).log(getFormatedTime(), "=>", ...data);
						}
						else {
							(0, console).log(...data);
						}

					}

					_executeCommands(showDetails, cmds);

				}).catch((err) => {
					(0, console).error(err);
					(0, process).exitCode = 1;
				});

			}

		}
336598
public void addCommands(Iterable<Command> commands) {
		Assert.notNull(commands, "Commands must not be null");
		for (Command command : commands) {
			addCommand(command);
		}
	}
1116
function commander (options) {
    const { cmds, version } = options
    const argvs = parseArgs()
    if (argvs._.length === 0) {
        if (argvs.v || argvs.version) {
            process.stdout.write(version + '\n' || 'unknow\n')
            process.exit()
        } else {
            help(options)
        }
    } else {
        const cmd = cmds.filter(function (v) {
            return v.command === argvs._[0] || v.aliases === argvs._[0]
        })[0]
        
        if (!cmd) {
            help(options)
        }
        cmd.module.handler(argvs)
    }
}
174291
function spawnCmd(command, args, options) {
    var d = Promise.defer();
    var child = spawn(command, args, options);

    child.on('error', function(error) {
        return d.reject(error);
    });

    child.stdout.on('data', function (data) {
        d.notify(data);
    });

    child.stderr.on('data', function (data) {
        d.notify(data);
    });

    child.on('close', function(code) {
        if (code === 0) {
            d.resolve();
        } else {
            d.reject(new Error('Error with command "'+command+'"'));
        }
    });

    return d.promise;
}
592064
function exec() {

  var actions = {
    commands: {
      init: { action: _init },
      run : { action: _run }
    }
  };

  cli.command(__dirname, actions);
}
320029
function onLine(line) {  // {{{2
//  console.log('CLI DATA', data);

  var that = this;

  readCommand(this, line, function(err) {
    if (err) O.log.error(err);

    that.iface.prompt();
  });
}
27598
function run(command) {
  const script = findScript(command);
  const config = findConfig();

  if (!script) {
    console.error(`ERROR: File not found: scripts/${command}.js`);
    process.exit(1);
  }

  const start = new Date();
  console.log(`Starting '${chalk.bold.gray(command)}'...`);

  return Promise.resolve().then(() => require(script)(config)).then(() => {
    console.log(
      `Finished '${chalk.bold.gray(command)}' after ` +
      `${chalk.bold(new Date().getTime() - start.getTime())}ms`
    );
  }, err => console.error(err.stack));
}
209626
function (data) {
    //console.log(data);
	data = data.toString();
	
    var para = data.replace('\n', ' ').split(' ');
    var command = para[0];
	var raw_para = data.replace(command, '');
	
	// remove first element as command
	para.splice(0, 1);
	
    // check if the command is registered
    if (l_handlers.hasOwnProperty(command)) {
        // prevent crashing from executing command
        if (UTIL.safeCall(l_handlers[command].handler, para, raw_para) === false) {
            console.log('  usage: ' + command + ' ' + l_handlers[command].usage);
            return;
        }
    }
	else
		console.log("type 'help' for a list of commands");
}
144169
function (commands) {
    this.activeCommands = [];

    this.setCommands(commands);

    this.currentTime = 0;

    this.keyboard = new Keyboard();
    this.gamepads = Gamepads.isSupported ? Gamepads : null;
}
279425
function(commands) {
		if (!commands || (commands.length === 0)) {
			return true;
		}
		if (typeof commands === 'string') {
			commands = [commands];
		}
		return commands.every(function(command) {
			logger.info('Starting command "%s"...', command);
			var result = exec(
				command,
				{cwd: path.resolve('.')}
			);
			if (result.status !== 0) { // error
				logger.error('Error: "%s" - "%s"', result.stdout, result.stderr.trim());
				return false;
			}
			logger.success('Command successfully finished');
			logger.log('Command result: "%s"', result.stdout);
			return true;
		});
	}
847637
function cli(args) {
    const { _: [command] } = args;
    return getModule(command).default(args)
        .catch(err => {
            getModule('input').emitError(err.message);
            process.exit(1);
        });
}
1328281
def _cmd(self, command, data=None, params=None, api_version=1):
    
    return self._post("commands/" + command, ApiCommand,
        data=data, params=params, api_version=api_version)
562050
function(command, arg) {
    if (!arg) {
      arg = 'default';
    }

    if (!commands[command]) {
      grunt.fail.fatal('Command [' + command + '] not found.');
    }

    // Check arg
    if (typeof (commands[command]) !== 'function') {
      if (!commands[command][arg]) {
        grunt.fail.fatal('Argument [' + arg + '] for [' + command
            + '] not found.');
      }
    }

    var func = (arg) ? commands[command][arg] : commands[command];
    if (!func) {
      func = commands[command]; // fallback to the main function
    }

    var options = this.options();
    var docker = (options.docker) ? new Docker(options.docker) : null;
    var done = this.async();

    var callback = function(e) {
      if (e) {
        grunt.fail.warn(e);
      }
      done();
    };

    func.apply(this, [ grunt, docker, options, callback, arg ]);
  }
390030
public static void main(String[] args) {
        try {
            ParsedCommandLine pcl = new ParsedCommandLine(args);
            Callable<String> command = pcl.getCommand();
            if (command == null) {
                System.out.println(pcl.getHelpText());
            } else {
                System.out.println(command.call());
            }
        } catch (Exception ex) {
            System.err.println("ERROR: " + ex.getMessage());
        }
    }