'Get the action the user wants to execute from the sys argv list.'

def set_action(self):

    for i in range(0, len(self.args)):
        arg = self.args[i]
        if (arg in self.VALID_ACTIONS):
            self.action = arg
            del self.args[i]
            break
    if (not self.action):
        tmp_parser = InvalidOptsParser(self.parser)
        (tmp_options, tmp_args) = tmp_parser.parse_args(self.args)
        if ((not (hasattr(tmp_options, 'help') and tmp_options.help)) or (hasattr(tmp_options, 'version') and tmp_options.version)):
            raise AnsibleOptionsError('Missing    required    action')
