How to use the argcomplete.autocomplete 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 pytest-dev / pytest / _pytest / _argcomplete.py View on Github external
def try_argcomplete(parser):
        argcomplete.autocomplete(parser, always_complete_options=False)
else:
github catboost / catboost / contrib / python / pytest / _pytest / _argcomplete.py View on Github external
def try_argcomplete(parser):
        argcomplete.autocomplete(parser, always_complete_options=False)
github CTSRD-CHERI / cheribuild / pycheribuild / jenkins.py View on Github external
def finalize_options(self, available_targets: list, **kwargs):
        target_option = self._parser.add_argument("targets", metavar="TARGET", nargs=argparse.OPTIONAL,
                                                  help="The target to build",
                                                  choices=available_targets + [EXTRACT_SDK_TARGET])
        if self._completing_arguments:
            try:
                import argcomplete
            except ImportError:
                sys.exit("argcomplete missing")
            target_completer = argcomplete.completers.ChoicesCompleter(available_targets)
            target_option.completer = target_completer
            argcomplete.autocomplete(
                self._parser,
                always_complete_options=None,  # don't print -/-- by default
                print_suppressed=True,  # also include target-specific options
                )
github aramis-lab / clinica / clinica / cmdline.py View on Github external
for p in [run_parser, io_parser, convert_parser, generate_parser]:
        p.error = single_error_message(p)

    # Do not want stderr message
    def silent_msg(x):
        pass

    parser.error = silent_msg

    """
    Parse the command and check that everything went fine
    """
    args = None
    unknown_args = None
    try:
        argcomplete.autocomplete(parser)
        args, unknown_args = parser.parse_known_args()
        if unknown_args:
            if ('--verbose' in unknown_args) or ('-v' in unknown_args):
                cprint("Verbose detected")
                args.verbose = True
            unknown_args = [i for i in unknown_args if i != '-v']
            unknown_args = [i for i in unknown_args if i != '--verbose']
            if unknown_args:
                print('%s[Warning] Unknown flag(s) detected: %s. This will be ignored by Clinica%s' %
                      (Fore.YELLOW, unknown_args, Fore.RESET))
    except SystemExit:
        exit(0)
    except Exception:
        print("%s\n[Error] You wrote wrong arguments on the command line. Clinica will now exit.\n%s" % (Fore.RED, Fore.RESET))
        parser.print_help()
        exit(-1)
github robocomp / robocomp / tools / buildTools / rccomp.py View on Github external
def main():
    parser = argparse.ArgumentParser(description="provides various info about components")
    parser.add_argument('argument', nargs='?', choices=['list'])
    
    argcomplete.autocomplete(parser)
    args = parser.parse_args()

    if args.argument=='list':
        components = WS.list_packages(WS.workspace_paths)
        componentsname=[]
        for component in components:
            componentsname.append(component.split('/')[ len(component.split('/')) -1 ])
        opstring = "   ".join(componentsname)
        print(opstring)
    else:
        parser.error("sorry no such option is available ")
github duerrp / pyexperiment / pyexperiment / experiment.py View on Github external
help="shortcut for --verbosity DEBUG")

    arg_parser.add_argument(
        '-j', '--processes',
        nargs=1,
        type=int,
        action='store',
        help="set number of parallel processes used")

    arg_parser.add_argument(
        '--print-timings',
        action='store_true',
        help="print logged timings")

    if AUTO_COMPLETION:
        argcomplete.autocomplete(arg_parser)

    return arg_parser
github cloudify-cosmo / cloudify-cli / cosmo_cli / cosmo_cli.py View on Github external
'-c', '--command',
        dest='ssh_command',
        metavar='COMMAND',
        default=None,
        type=str,
        help='Execute command over SSH'
    )
    parser_ssh.add_argument(
        '-p', '--plain',
        dest='ssh_plain_mode',
        action='store_true',
        help='Leave authentication to user'
    )
    _set_handler_for_command(parser_ssh, _run_ssh)

    argcomplete.autocomplete(parser)
    parsed = parser.parse_args(args)
    set_global_verbosity_level(parsed.verbosity)
    return parsed
github wpilibsuite / frc-characterization / frc_characterization / cli / __init__.py View on Github external
"mech_type",
            choices=list(tool_dict.keys()),
            help="Mechanism type being characterized",
        )
        parser.add_argument(
            "tool_type",
            choices=list(list(tool_dict.values())[0].keys()),
            help="Create new project, start data recorder/logger, or start data analyzer",
        )
        parser.add_argument(
            "project_directory",
            help="Location for the project directory (if creating a new project)",
            nargs="?",
            default=None,
        )
        argcomplete.autocomplete(parser)

        args = parser.parse_args()
        tool_dict[args.mech_type][args.tool_type](directory=args.project_directory)
github XiaoMi / galaxy-fds-sdk-python / fds / fds_cmd.py View on Github external
help='''Put or get lifecycle configof the bucket. Please use \\" instead of " in this argument when putting lifecycle config due to shell may eat double quotes.''')

  group = parser.add_argument_group('acl')
  group.add_argument('--gratee',
                      nargs='+',
                      metavar='user, group, ALL_USERS, AUTHENTICATED_USERS',
                      dest='gratee',
                      help='Add acl to bucket')
  group.add_argument('--permission',
                      nargs='?',
                      metavar="READ, WRITE, READ_OBJECTS, FULL_CONTROL",
                      dest='permission',
                      choices=['READ', 'WRITE', 'READ_OBJECTS', 'FULL_CONTROL'],
                      help='Add acl to bucket')

  argcomplete.autocomplete(parser)

  args = parser.parse_args()

  # set logging
  log_format = '%(asctime)-15s [%(filename)s:%(lineno)d] %(message)s'
  logging.basicConfig(format=log_format)
  global logger
  logger = logging.getLogger('fds.cmd')
  debug_enabled = args.debug

  if debug_enabled:
    logger.setLevel(logging.DEBUG)
  else:
    logger.setLevel(logging.INFO)
  ## read config
  parse_argument(args=args)
github haaksmash / flowhub / flowhub / core.py View on Github external
help='Shorthand for using the flag -urt')

    #
    # Issues
    #
    issue_subs = issue.add_subparsers(dest='action')
    istart = issue_subs.add_parser('start',
        help="Open a new issue on github")
    istart.add_argument('title', nargs='?', default=None, action='store',
        help="Title of the created issue")
    istart.add_argument('--labels', '-l', default=None, action='store',
        help='Comma-separated list of labels to apply to this bug.\nLabels that don\'t exist won\'t be applied.')
    istart.add_argument('--create-branch', '-b', default=False, action='store_true',
        help="Create a feature branch for this issue.")

    argcomplete.autocomplete(parser)
    args = parser.parse_args()
    if args.verbosity > 2:
        print "Args: ", args

    # Force initialization to run offline.
    if args.subparser == 'init':
        e = Engine(debug=args.verbosity, init=True, offline=True)
        handle_init_call(args, e)
        return

    else:
        e = Engine(debug=args.verbosity, offline=args.offline)

    if args.subparser == 'feature':
        handle_feature_call(args, e)