Return args already used in the
        command line

        rtype: command.Arg generator
171723
def used_args(self):
        
        # get all arguments values from the command line
        values = []
        for idx, c in enumerate(self.words[1:]):
            if c.startswith('-'):
                continue
            option_str = self.words[1:][idx - 1]
            option = self.get_option(option_str)
            if option is None or not option.need_value:
                values.append((c, c == self.document.get_word_before_cursor(WORD=True)))
        logger.debug("Found args values %s" % values)
        # consume values
        for arg in self.cmd.args.values():
            if not values:
                raise StopIteration
            if arg.is_multiple:
                values = []
                yield arg
            elif type(arg.nargs) is int:
                for _ in range(arg.nargs):
                    value = values.pop(0)
                    # not the current argument
                    if value[1] is False:
                        yield arg
                    if not values:
                        raise StopIteration
1086135
def _get_subparser_line_args(self, subparser_prog):
    

    subparsers = self._get_subparsers()
    for subparser in subparsers:
      if subparser_prog == subparser.prog:
        # Found the subparser.
        args_to_parse = []
        for action in subparser._actions:
          if action.option_strings:
            for argname in action.option_strings:
              if argname.startswith('--'):
                args_to_parse.append(argname[2:])
        return args_to_parse

    return None
325639
def getArguments(parser):
    ""
    args = parser.parse_args()    
    # check output image exists if override not forced
    if not args.force:
        if os.path.exists(args.output + args.image[-4:]):
            raise ArgumentError('The supplied output file {} already exists. Run -f/force flag to override.'.format(args.output))

    return args
1337937
def load_args(self, args, clargs):
        
        # Parse All Arguments
        args = self.parser.parse_args(args=clargs, namespace=args)

        # Print the help information if no subcommand is given
        # subcommand is required for operation
        if args.subcommand is None:
            self.parser.print_help()
            args = None

        return args
788464
def getargs():
    
    parser = argparse.ArgumentParser(description='\
    Select paths from a directory tree.')
    parser.add_argument("-a", "--hidden", action="store_false",
                        help="Show all hidden paths too.")
    parser.add_argument("-r", "--relative", action="store_true",
                        help="Output relative paths.")
    parser.add_argument("path", type=chkpath, nargs='?',
                        default=".", help="A valid path.")
    return parser.parse_args()
141824
def _clone_args(self):
        
        keys = list(self.keys)
        kw = {}
        if self.allow_any or self.extras:
            kw['allow_extra'] = list(self.extras)
            if self.allow_any:
                kw['allow_extra'].append('*')
            kw['allow_extra_trafaret'] = self.extras_trafaret
        if self.ignore_any or self.ignore:
            kw['ignore_extra'] = list(self.ignore)
            if self.ignore_any:
                kw['ignore_any'].append('*')
        return keys, kw
209898
def generator(self,gen,*args,**kwargs):
        
        with self(*args,**kwargs):
            for i in gen:
                yield i
638124
def args(self, args):
        '''
        '''
        self._args = args
        self._logger.log('debug', 'Args set to {}'.format(args))
1156826
def get_args_tuple(args, kwargs, arg_names, kwargs_defaults):
    """"""
    args_list = list(args)
    args_len = len(args)
    all_args_len = len(arg_names)
    try:
        while args_len < all_args_len:
            arg_name = arg_names[args_len]
            if arg_name in kwargs_defaults:
                args_list.append(kwargs.get(arg_name, kwargs_defaults[arg_name]))
            else:
                args_list.append(kwargs[arg_name])
            args_len += 1
    except KeyError as e:
        raise TypeError("Missing argument %r" % (e.args[0],))
    return tuple(args_list)
794078
def get_cmdline_varargs(argv=None):
    
    if argv is None:
        argv = sys.argv
    scriptname = argv[0]
    if scriptname == '':
        # python invoked by iteself
        pos_start = 0
        pos_end = 0
    else:
        pos_start = pos_end = 1
        for idx in range(pos_start, len(argv)):
            if argv[idx].startswith('-'):
                pos_end = idx
                break
        else:
            pos_end = len(argv)
    cmdline_varargs = argv[pos_start:pos_end]
    return cmdline_varargs
146443
def argnames(self):
        
        # pylint: disable=no-member; github.com/pycqa/astroid/issues/291
        # args is in fact redefined later on by postinit. Can't be changed
        # to None due to a strong interaction between Lambda and FunctionDef.

        if self.args.args:  # maybe None with builtin functions
            names = _rec_get_names(self.args.args)
        else:
            names = []
        if self.args.vararg:
            names.append(self.args.vararg)
        if self.args.kwarg:
            names.append(self.args.kwarg)
        return names
480682
def _get_args(self):
        
        if not hasattr(self, '_args_evaled'):
            # cache the args in case handler is re-invoked due to flags change
            self._args_evaled = list(chain.from_iterable(self._args))
        return self._args_evaled
172580
def _command_and_args(tokens: List[str]) -> Tuple[str, str]:
        
        command = ''
        args = ''

        if tokens:
            command = tokens[0]

        if len(tokens) > 1:
            args = ' '.join(tokens[1:])

        return command, args
1365147
def _get_arg_tokens(cli):
    
    arg = cli.input_processor.arg

    return [
        (Token.Prompt.Arg, '(arg: '),
        (Token.Prompt.Arg.Text, str(arg)),
        (Token.Prompt.Arg, ') '),
    ]
922346
def get_args():
    
    expected = ['working_directory', 'operating_system', 'version']
    possible = ['json'].extend(expected)
    try:
        opts, args = getopt.getopt(sys.argv[1:], '', map(lambda x: ('%s=' % x),
                                   possible))
    except getopt.GetoptError as err:
        print(str(err))
        exit_cleanly(error_number=errno.EINVAL)
    arguments = dict()
    for o, a in opts:
        option = re.sub('^-*', '', o)
        if 'json' in option:
            arguments = _load_json(a)
            break
        if option in expected:
            arguments[option] = a
    error = 0
    for item in expected:
        if item not in arguments:
            print("Missing: %s from arguments" % item)
            error = errno.EINVAL
    if error:
        exit_cleanly(error_number=error)
    return arguments
130673
def args(self):
        
        if not self._parsed:  # only resolve once
            self._default_args, unknown = self.parser.parse_known_args()

            # when running locally retrieve any args from the results.tc file.  when running in
            # platform this is done automatically.
            self._results_tc_args()

            # log unknown arguments only once
            self._unknown_args(unknown)

            # set parsed bool to ensure args are only parsed once
            self._parsed = True

            # update args with value from config data or configuration file
            self.args_update()

        return self._default_args
305239
def with_trailing_args(self, *arguments):
        
        new_command = copy.deepcopy(self)
        new_command._trailing_args = [str(arg) for arg in arguments]
        return new_command