How to use the argcomplete.completers.DirectoriesCompleter function in argcomplete

To help you get started, we’ve selected a few argcomplete examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vusec / instrumentation-infra / infra / commands / report.py View on Github external
Valid aggregations are
                mean|median|stdev|stdev_percent|mad|min|max|
                sum|count|first|same|one|all|geomean
                (stdev_percent = 100*stdev/mean,
                mad = median absolute deviation,
                same = asserts each value is the same,
                all = join values by space,
                sort = join sorted values by space)''')
            tparser.add_argument('--help-fields', action='store_true',
                    help='print valid values for --field')
            tparser.add_argument('--aggregate', choices=_aggregate_fns,
                    help='aggregation method for entire columns')

            try:
                from argcomplete.completers import DirectoriesCompleter
                rundirsarg.completer = DirectoriesCompleter()
                fieldarg.completer = _FieldCompleter(target)
            except ImportError:
                pass
github Azure / azure-cli / src / azure-cli / azure / cli / command_modules / batch / _command_type.py View on Github external
required=False,
                                                       default=None,
                                                       type=file_type,
                                                       completer=FilesCompleter(),
                                                       help=docstring)))
            elif arg[0] not in pformat.IGNORE_PARAMETERS:
                args.append(arg)
        return_type = find_return_type(handler)
        if return_type and return_type.startswith('Generator'):
            param = 'destination'
            docstring = "The path to the destination file or directory."
            args.append((param, CLICommandArgument(param,
                                                   options_list=[arg_name(param)],
                                                   required=True,
                                                   default=None,
                                                   completer=DirectoriesCompleter(),
                                                   type=file_type,
                                                   validator=validators.validate_file_destination,
                                                   help=docstring)))
        if return_type == 'None' and handler.__name__.startswith('get'):
            self._head_cmd = True
        if self.confirmation:
            param = CONFIRM_PARAM_NAME
            docstring = 'Do not prompt for confirmation.'
            args.append((param, CLICommandArgument(param,
                                                   options_list=['--yes', '-y'],
                                                   required=False,
                                                   action='store_true',
                                                   help=docstring)))
        auth_group_name = 'Batch Account'
        args.append(('cmd', CLICommandArgument('cmd', action=IgnoreAction)))
        args.append(('account_name', CLICommandArgument(
github ccbrown / needy / needy / command.py View on Github external
def completer(f):
    @wraps(f)
    def wrapper(parsed_args, **kwds):
        import argcomplete
        try:
            with cd(parsed_args.C) if getattr(parsed_args, 'C', None) else DummyContextManager() as _:
                return f(parsed_args=parsed_args, **kwds)
        except Exception as e:
            argcomplete.warn('An error occurred during argument completion: {}'.format(e))
    return wrapper


try:
    from argcomplete.completers import DirectoriesCompleter
    directory_completer = DirectoriesCompleter()
except ImportError:
    directory_completer = None


@completer
def library_completer(prefix, parsed_args, **kwargs):
    with ConfiguredNeedy('.', parsed_args) as needy:
        target_or_universal_binary = parsed_args.universal_binary if getattr(parsed_args, 'universal_binary', None) else needy.target(getattr(parsed_args, 'target', 'host'))
        return [name for name in needy.libraries(target_or_universal_binary).keys() if name.startswith(prefix)]


@completer
def target_completer(prefix, **kwargs):
    if ':' in prefix:
        # architectures don't have any formal constraints, but we can provide some common ones
        architectures = ['x86_64', 'i386', 'armv7', 'arm64', 'amd64']