Detect if the option -m is present in the command
488183
function _detectComment(argv){
  var comment = ''
  if(argv._.length == 1){
    if(argv.m && typeof argv.m == 'string') comment = argv.m
    else if (argv.message && typeof argv.message == 'string') comment = argv.message
    return comment
  } else {
    console.log(chalk.red.bold('Invalid command: use stamplay deploy -m "YOUR MESSAGE"'))
    process.exit(1)
  }
}
1319908
def has_command(self, command):
        """"""
        for pbt in self._plugins.values():
            if pbt.command == command:
                return True
        return False
883889
def check_shell_redirection(cmd):
    
    curly_brackets = True
    while curly_brackets:
        SRE_match_obj = re.search(r'\{(.*?)}',cmd)
        if SRE_match_obj is not None:
            cmd = cmd[:SRE_match_obj.start()] + cmd[(SRE_match_obj.end()+1):]
            if re.search(r'\{(.*?)}',cmd) is None:
                curly_brackets = False
        else:
            curly_brackets = False
    return ">" in cmd
836035
def confirm(prompt, default=None, show_default=True, abort=False, input_function=None):
	'''
	'''
	valid = {
		'yes': True,
		'y': True,
		'no': False,
		'n': False
	}
	input_function = get_input_fn(input_function)
	if default not in ['yes', 'no', None]:
		default = None
	if show_default:
		prompt = '{} [{}/{}]: '.format(prompt,
				'Y' if default == 'yes' else 'y',
				'N' if default == 'no' else 'n')
	while True:
		choice = prompt_fn(input_function, prompt, default).lower()
		if choice in valid:
			if valid[choice] == False and abort:
				raise_abort()
			return valid[choice]
		else:
			echo('Please respond with "yes" or "no" (or "y" or "n").')
796509
private String checkinScriptCommand() {

        String exportModules = "";
        if ((m_modulesToExport != null) && !m_modulesToExport.isEmpty()) {
            StringBuffer exportModulesParam = new StringBuffer();
            for (String moduleName : m_modulesToExport) {
                exportModulesParam.append(" ").append(moduleName);
            }
            exportModulesParam.replace(0, 1, " \"");
            exportModulesParam.append("\" ");
            exportModules = " --modules " + exportModulesParam.toString();

        }
        String commitMessage = "";
        if (m_commitMessage != null) {
            commitMessage = " -msg \"" + m_commitMessage.replace("\"", "\\\"") + "\"";
        }
        String gitUserName = "";
        if (m_gitUserName != null) {
            if (m_gitUserName.trim().isEmpty()) {
                gitUserName = " --ignore-default-git-user-name";
            } else {
                gitUserName = " --git-user-name \"" + m_gitUserName + "\"";
            }
        }
        String gitUserEmail = "";
        if (m_gitUserEmail != null) {
            if (m_gitUserEmail.trim().isEmpty()) {
                gitUserEmail = " --ignore-default-git-user-email";
            } else {
                gitUserEmail = " --git-user-email \"" + m_gitUserEmail + "\"";
            }
        }
        String autoPullBefore = "";
        if (m_autoPullBefore != null) {
            autoPullBefore = m_autoPullBefore.booleanValue() ? " --pull-before " : " --no-pull-before";
        }
        String autoPullAfter = "";
        if (m_autoPullAfter != null) {
            autoPullAfter = m_autoPullAfter.booleanValue() ? " --pull-after " : " --no-pull-after";
        }
        String autoPush = "";
        if (m_autoPush != null) {
            autoPush = m_autoPush.booleanValue() ? " --push " : " --no-push";
        }
        String exportFolder = " --export-folder \"" + m_currentConfiguration.getModuleExportPath() + "\"";
        String exportMode = " --export-mode " + m_currentConfiguration.getExportMode();
        String excludeLibs = "";
        if (m_excludeLibs != null) {
            excludeLibs = m_excludeLibs.booleanValue() ? " --exclude-libs" : " --no-exclude-libs";
        }
        String commitMode = "";
        if (m_commitMode != null) {
            commitMode = m_commitMode.booleanValue() ? " --commit" : " --no-commit";
        }
        String ignoreUncleanMode = "";
        if (m_ignoreUnclean != null) {
            ignoreUncleanMode = m_ignoreUnclean.booleanValue() ? " --ignore-unclean" : " --no-ignore-unclean";
        }
        String copyAndUnzip = "";
        if (m_copyAndUnzip != null) {
            copyAndUnzip = m_copyAndUnzip.booleanValue() ? " --copy-and-unzip" : " --no-copy-and-unzip";
        }

        String configFilePath = m_currentConfiguration.getFilePath();

        return "\""
            + DEFAULT_SCRIPT_FILE
            + "\""
            + exportModules
            + commitMessage
            + gitUserName
            + gitUserEmail
            + autoPullBefore
            + autoPullAfter
            + autoPush
            + exportFolder
            + exportMode
            + excludeLibs
            + commitMode
            + ignoreUncleanMode
            + copyAndUnzip
            + " \""
            + configFilePath
            + "\"";
    }
14300
def postcmd(self):
        """"""
        value = self.choice.get()
        try:
            index = self.paramInfo.choice.index(value)
            self.entry.menu.activate(index)
        except ValueError:
            # initial null value may not be in list
            pass
29069
def menu_callback(m):
    ''''''
    if m.returnkey.startswith('# '):
        cmd = m.returnkey[2:]
        if m.handler is not None:
            if m.handler_result is None:
                return
            cmd += m.handler_result
        process_stdin(cmd)
    elif m.returnkey == 'menuSettings':
        wxsettings.WXSettings(mestate.settings)
    elif m.returnkey.startswith("mode-"):
        idx = int(m.returnkey[5:])
        mestate.flightmode_selections[idx] = m.IsChecked()
    elif m.returnkey.startswith("loadLog"):
        print("File: " + m.returnkey[8:])
    elif m.returnkey == 'quit':
        mestate.console.close()
        mestate.exit = True
        print("Exited. Press Enter to continue.")
        sys.exit(0)

    else:
        print('Unknown menu selection: %s' % m.returnkey)
50885
def available(name):
    '''
    
    '''
    cmd = '{0} get {1}'.format(_cmd(), name)
    if __salt__['cmd.retcode'](cmd) == 2:
        return False
    return True
365736
private void determineCommand() {
        command = null;
        commandStr = null;

        boolean tooManyCommands = false;
        for (Command c : Command.values()) {
            final String alias = c.getAlias();
            if (hasOption(alias)) {
                if (c == Command.HELP) {
                    // `--help` can be a command or just a long option for another command.
                    help = true;
                } else if (command == null) {
                    // Found a command option
                    command = c;
                    commandStr = alias;
                } else {
                    tooManyCommands = true;
                }
            }
        }

        if (tooManyCommands) {
            command = null;
            commandStr = null;

            if (!help) {
                reportable.error(format(
                        "You must specify only one command (%s).%n",
                        showCommandAliases()));
                printHelp(true);
            }
        }
        if (help && command == null) {
            // `--help` is considered as the command if no other command is provided.
            command = Command.HELP;
            commandStr = command.getAlias();

        } else if (command == null) {
        	// Print usage if no commands were specified
        	printUsage();
        	reportable.error("\n");
            reportable
                    .error("No command option given. Please specify one of:  "
                            + showCommandAliases());
            end();
        }
    }
415203
def check_process_by_name(self, process):
        """"""
        status = False
        cmd_line_glob = "/proc/[0-9]*/cmdline"
        try:
            cmd_line_paths = glob.glob(cmd_line_glob)
            for path in cmd_line_paths:
                f = open(path, 'r')
                cmd_line = f.read().strip()
                if process in cmd_line:
                    status = True
        except IOError as e:
            return False
        return status
1348241
public static boolean findBooleanOption(String[] args, String option) {
        for (int i = 0; i<args.length; ++i) {
            if (args[i].equals(option)) return true;
        }
        return false;
    }
1304058
def _has_option(option, family='ipv4'):
    '''
    
    '''
    cmd = '{0} --help'.format(_iptables_cmd(family))
    if option in __salt__['cmd.run'](cmd, output_loglevel='quiet'):
        return True
    return False
946717
def check_command(self, command):
        

        # Use `command` to see if command is callable, store exit code
        code = os.system("command -v {0} >/dev/null 2>&1 || {{ exit 1; }}".format(command))

        # If exit code is not 0, report which command failed and return False, else return True
        if code != 0:
            print("Command is not callable: {0}".format(command))
            return False
        else:
            return True
1041764
def _check_local_option(self, option):
        """"""
        if not self.telnet_opt_dict.has_key(option):
            self.telnet_opt_dict[option] = TelnetOption()
        return self.telnet_opt_dict[option].local_option
766305
def hasOption(self, name):
    
    name = name.strip()
    for o in self.options:
      if o.short == name or o.long == name:
        return True
    return False
746306
def has_option?(option) #:nodoc:
      option = option.gsub(/^\-+/,'')
      ((flags.values.map { |_| [_.name,_.aliases] }) + 
       (switches.values.map { |_| [_.name,_.aliases] })).flatten.map(&:to_s).include?(option)
    end
514376
def decide(self):
        

        next_command_name = random.choice(self.COMMAND_MAP[self.state['last_command']])
        param = ''
        if next_command_name == 'cd':
            try:
                param = random.choice(self.state['dir_list'])
            except IndexError:
                next_command_name = 'ls'

        elif next_command_name == 'uname':
            opts = 'asnrvmpio'
            start = random.randint(0, len(opts) - 2)
            end = random.randint(start + 1, len(opts) - 1)
            param = '-{}'.format(opts[start:end])
        elif next_command_name == 'ls':
            if random.randint(0, 1):
                param = '-l'
        elif next_command_name == 'cat':
            try:
                param = random.choice(self.state['file_list'])
            except IndexError:
                param = ''.join(random.choice(string.lowercase) for x in range(3))
        elif next_command_name == 'echo':
            param = random.choice([
                '$http_proxy',
                '$https_proxy',
                '$ftp_proxy',
                '$BROWSER',
                '$EDITOR',
                '$SHELL',
                '$PAGER'
            ])
        elif next_command_name == 'sudo':
            param = random.choice([
                'pm-hibernate',
                'shutdown -h',
                'vim /etc/httpd.conf',
                'vim /etc/resolve.conf',
                'service network restart',
                '/etc/init.d/network-manager restart',
            ])
        return next_command_name, param