////////////////////////////////////////////////////////////////////////////////
// Run the alias command.
9848
func aliasCmd(args []string, aliases *Aliases) error {
	if len(args) >= 2 {
		var eth string
		if len(args) > 2 {
			eth = args[2]
		}
		// TODO: Validate mac address
		alias, mac := args[0], args[1]
		return aliases.Add(alias, mac, eth)
	}
	return errors.New("alias command requires a <name> and a <mac>")
}
605735
function Command(name, parent) {
  if (!(this instanceof Command)) {
    return new Command();
  }
  this.commands = [];
  this.options = [];
  this._args = [];
  this._aliases = [];
  this._name = name;
  this._relay = false;
  this._hidden = false;
  this._parent = parent;
  this._mode = false;
  this._catch = false;
  this._help = undefined;
  this._init = undefined;
  this._after = undefined;
  this._allowUnknownOptions = false;
}
1231683
function run()
    {
        switch ($this->cmd) {
            case 'generate':
                return $this->cmdGenerate();
                break;

            case 'list':
                return $this->cmdList();
                break;

            default:
                echo "\n\n  Command \"key:".$this->cmd."\" not exists!";
                exit(Main::help());
                break;
        }
        return;
    }
47063
function run(command, auth, options, async, done, msgSuccess, msgSuccessAsync, msgFailure) {

        var args,
            flags,
            field,
            i,
            childProcess;

        // Pass auth.
        command = command.replace('{auth}', auth ? format('--email=%s --passin ', auth.email) : '');

        // Evaluate arguments to pass.
        args = '';
        for (field in options.args) {
            args += format('--%s=%s ', field, options.args[field]);
        }

        // Evaluate flags to pass.
        flags = '';
        for (i = 0; i < options.flags.length; ++i) {
            flags += format('--%s ', options.flags[i]);
        }

        command = command.replace('{args}', args).replace('{flags}', flags).replace('{path}', options.path);

        // Passin.
        if (auth) {
            command = format('echo %s | %s', auth.password, command);
        }

        // Run it asynchronously
        if (async) {
            command = COMMAND_ASYNC.
                replace('{command}', command).
                replace('{redirect}', options.asyncOutput ? '' : REDIRECT_DEVNULL);
        }

        grunt.log.debug(command);

        // Run the command.
        childProcess = exec(command, {}, function () {});

        // Listen to output
        if (options.stdout) {
            childProcess.stdout.on('data', function (d) {
                grunt.log.write(d);
            });
        }

        // Listen to errors.
        if (options.stderr) {
            childProcess.stderr.on('data', function (d) {
                grunt.log.error(d);
            });
        }

        // Listen to exit.
        childProcess.on('exit', function (code) {
            if (options.stdout) {
                if (code === 0 && async) {
                    grunt.log.subhead(
                        msgSuccessAsync ||
                        options.asyncOutput && 'Output from asynchronous operation follows.' ||
                        'Unable to determine success of asynchronous operation. For debugging please disable async mode or enable asyncOutput.'
                    );
                } else if (code === 0) {
                    grunt.log.ok(msgSuccess || 'Action executed successfully.');
                }
            }

            if (options.stderr && code !== 0) {
                grunt.log.error(msgFailure || 'Error executing the action.');
            }

            done();
        });

    }
343954
def write_aliases(aliases, tempdir):
    

    platform = lib.platform()
    if platform == "unix":
        home_alias = "cd $BE_DEVELOPMENTDIR"
    else:
        home_alias = "cd %BE_DEVELOPMENTDIR%"

    aliases["home"] = home_alias

    tempdir = os.path.join(tempdir, "aliases")
    os.makedirs(tempdir)

    for alias, cmd in aliases.iteritems():
        path = os.path.join(tempdir, alias)

        if platform == "windows":
            path += ".bat"

        with open(path, "w") as f:
            f.write(cmd)

        if platform == "unix":
            # Make executable
            st = os.stat(path)
            os.chmod(path, st.st_mode | stat.S_IXUSR
                     | stat.S_IXGRP | stat.S_IXOTH)

    return tempdir
472541
public function cmdGenerateAlias()
    {
        $entity = $this->getParam(0);
        $entity_id = $this->getParam(1);
        $all = $this->getParam('all');

        if (empty($entity)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        if (!isset($entity_id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = false;

        if (isset($entity_id)) {

            if (!is_numeric($entity_id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $data = $this->alias->loadEntity($entity, $entity_id);

            if (empty($data)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $alias = $this->alias->generateEntity($entity, $data);

            if (empty($alias)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }

            $result = $this->addAlias($entity, $entity_id, $alias);

        } else if (!empty($all)) {
            $result = $this->generateListAlias($entity);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
374769
def run(self, *args):
        
        if self.prefix_char is None:
            prefix_char = config.suite_alias_prefix_char
        else:
            prefix_char = self.prefix_char

        if prefix_char == '':
            # empty prefix char means we don't support the '+' args
            return self._run_no_args(args)
        else:
            return self._run(prefix_char, args)
335599
function parseCommandLine(args) {

    var parsed_cmds = [];

    if (args.length <= 2) {
        parsed_cmds.push(defaultCommand());
    } else {

        var cli = args.slice(2);

        var pos = 0;
        var cmd;

        cli.forEach(function(element, index, array) {

            //replace alias name with real name.
            if (element.indexOf('--') === -1 && element.indexOf('-') === 0) {
                cli[index] = alias_map[element];
            }

            //parse command and args
            if (cli[index].indexOf('--') === -1) {
                cmd.args.push(cli[index]);
            } else {

                if (keys[cli[index]] == "undefined") {
                    throw new Error("not support command:" + cli[index]);
                };

                pos = index;
                cmd = commands[cli[index]];
                if (typeof cmd.args == 'undefined') {
                    cmd.args = [];
                };
                parsed_cmds.push(cmd);
            }
        });
    };

    return parsed_cmds;
}
351674
def run_command(cmd, root, dst, input, params):
    
    use_stdout = '{output}' not in cmd
    if not use_stdout:
        params['output'] = dst
    parsed_cmd = parse_command(cmd, input=input, params=params)

    ensure_dirs(os.path.join(root, dst))

    logger.info("Running [%s] from [%s]", parsed_cmd, root)

    proc = subprocess.Popen(
        args=parsed_cmd,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True,
        cwd=root,
    )
    (stdout, stderr) = proc.communicate()

    assert not proc.returncode, stderr

    if use_stdout:
        # TODO: this should probably change dest to be a temp file
        with open(os.path.join(root, dst), 'w') as fp:
            fp.write(stdout)
308498
public function addCommand($callback, $alias = null, $default = false)
    {
        if ($alias instanceof \Closure && is_string($callback)) {
            list($alias, $callback) = array($callback, $alias);
        }
        if (is_array($callback) && is_string($callback[0])) {
            $callback = implode('::', $callback);
        }
        
        $name = '';
        if (is_string($callback)) {
            $name = $callback;
            if (is_callable($callback)) {
                if (strpos($callback, '::') !== false) {
                    list($classname, $methodname) = explode('::', $callback);
                    $name = Utils::dashized($methodname);
                } else {
                    $name = strtolower(trim(str_replace('_', '-', $name), '-'));
                }
            } else {
                if (substr($name, -7) === 'Command') {
                    $name = substr($name, 0, -7);
                }
                $name = Utils::dashized(basename(str_replace('\\', '/', $name)));
            }
        } else if (is_object($callback) && !($callback instanceof Closure)) {
            $classname = get_class($callback);
            if (!($callback instanceof Command)) {
                throw new ConsoleException("'$classname' must inherit from 'ConsoleKit\Command'");
            }
            if (substr($classname, -7) === 'Command') {
                $classname = substr($classname, 0, -7);
            }
            $name = Utils::dashized(basename(str_replace('\\', '/', $classname)));
        } else if (!$alias) {
            throw new ConsoleException("Commands using closures must have an alias");
        }

        $name = $alias ?: $name;
        $this->commands[$name] = $callback;
        if ($default) {
            $this->defaultCommand = $name;
        }
        return $this;
    }
991210
def run(self):
        
        args = self._process_flags()

        self.todofile = TodoFile.TodoFile(config().todotxt())
        self.todolist = TodoList.TodoList(self.todofile.read())

        try:
            (subcommand, args) = get_subcommand(args)
        except ConfigError as ce:
            error('Error: ' + str(ce) + '. Check your aliases configuration')
            sys.exit(1)

        if subcommand is None:
            CLIApplicationBase._usage()

        if self._execute(subcommand, args) == False:
            sys.exit(1)
        else:
            self._post_execute()
1273190
def add_command_alias(command_name, alias_command, callback) #:nodoc:
      original_command = @commands[:meta][command_name]
      original_command[:syntax] << alias_command[:syntax]

      alias_name = command_name(alias_command[:syntax])

      alias_command[:is_public] = original_command[:is_public]

      add_command_meta(alias_name, original_command, true)
      add_command_spec(alias_command, callback)
    end
440662
def do(cmdline=None, runas=None):
    '''
    
    '''
    path = _pyenv_path(runas)
    cmd_split = cmdline.split()
    quoted_line = ''
    for cmd in cmd_split:
        quoted_line = quoted_line + ' ' + _cmd_quote(cmd)
    result = __salt__['cmd.run_all'](
        'env PATH={0}/shims:$PATH {1}'.format(_cmd_quote(path), quoted_line),
        runas=runas,
        python_shell=True
    )

    if result['retcode'] == 0:
        rehash(runas=runas)
        return result['stdout']
    else:
        return False
934054
def run (cmd, verbosity=0, **kwargs):
    """"""
    # Note that shell_quote_nt() result is not suitable for copy-paste
    # (especially on Unix systems), but it looks nicer than shell_quote().
    if verbosity >= 0:
        log_info("running %s" % " ".join(map(shell_quote_nt, cmd)))
    if kwargs:
        if verbosity >= 0:
            log_info("    with %s" % ", ".join("%s=%s" % (k, shell_quote(str(v)))\
                                           for k, v in kwargs.items()))
        if kwargs.get("shell"):
            # for shell calls the command must be a string
            cmd = " ".join(cmd)
    if verbosity < 1:
        # hide command output on stdout
        with open(os.devnull, 'wb') as devnull:
            kwargs['stdout'] = devnull
            res = subprocess.call(cmd, **kwargs)
    else:
        res = subprocess.call(cmd, **kwargs)
    return res
15196
func main() {
	var args []string

	// Detect the current user to figure out what their ~ is.
	usr, err := user.Current()
	fatalOnError(err)

	// Load the list of aliases from the file at dbPath.
	aliases, err := LoadAliases(path.Join(usr.HomeDir, dbPath))
	fatalOnError(err)
	defer aliases.Close()

	// Parse arguments which might get passed to "wol".
	parser := flags.NewParser(&cliFlags, flags.Default & ^flags.HelpFlag)
	args, err = parser.Parse()

	ec := 0
	switch {

	// Parse Error, print usage.
	case err != nil:
		ec = printUsageGetExitCode("", 1)

	// No arguments, or help requested, print usage.
	case len(os.Args) == 1 || cliFlags.Help:
		ec = printUsageGetExitCode("", 0)

	// "--version" requested.
	case cliFlags.Version:
		fmt.Printf("%s\n", wol.Version)

	// Make sure we are being asked to run a something.
	case len(args) == 0:
		ec = printUsageGetExitCode("No command specified, see usage:\n", 1)

	// All other cases go here.
	case true:
		cmd, cmdArgs := strings.ToLower(args[0]), args[1:]
		if fn, ok := cmdMap[cmd]; ok {
			err = fn(cmdArgs, aliases)
		} else {
			err = wakeCmd(args, aliases)
		}
		fatalOnError(err)
	}
	os.Exit(ec)
}
1170210
function run(params, command, callback)
{
  var job;

  // decouple commands
  command = clone(command);

  // start command execution and get job reference
  job = executioner(command, stringify(extend(this, params)), this.options || {}, callback);

  // make ready to call task termination function
  return partial(executioner.terminate, job);
}
489232
def run_command(self, command_name, varargs):
        
        command_descriptor = self.get_command(command_name)
        return command_descriptor.run(*varargs)