當前位置: 首頁>>代碼示例>>Python>>正文


Python argcomplete.autocomplete方法代碼示例

本文整理匯總了Python中argcomplete.autocomplete方法的典型用法代碼示例。如果您正苦於以下問題:Python argcomplete.autocomplete方法的具體用法?Python argcomplete.autocomplete怎麽用?Python argcomplete.autocomplete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在argcomplete的用法示例。


在下文中一共展示了argcomplete.autocomplete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def main():
    """Main CLI application."""

    parser = get_parser()

    argcomplete.autocomplete(parser, always_complete_options=False)

    args = parser.parse_args()
    if not args.command:
        args.command = "aggregate"

    setup_logger(
        level=args.log_level
    )

    try:
        run(args)
    except KeyboardInterrupt:
        pass 
開發者ID:acsone,項目名稱:git-aggregator,代碼行數:21,代碼來源:main.py

示例2: list_module_options

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def list_module_options(module, module_name):

    config = get_config_options()
    db = initialize_database(config)
    # Load the module
    Module = load_module(module)
    if Module.Module.__doc__:
        print("%s" % module_name)

        print(Module.Module.__doc__)
    m = Module.Module(db)

    # Populate the options
    m.set_options()
    argcomplete.autocomplete(m.options)
    m.options.parse_args(["-h"]) 
開發者ID:depthsecurity,項目名稱:armory,代碼行數:18,代碼來源:armory.py

示例3: list_report_options

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def list_report_options(module, module_name):

    config = get_config_options()
    db = initialize_database(config)
    # Load the module
    Module = load_module(module)
    if Module.Report.__doc__:
        print("%s" % module_name)

        print(Module.Report.__doc__)

    m = Module.Report(db)

    # Populate the options
    m.set_options()
    argcomplete.autocomplete(m.options)
    m.options.parse_args(["-h"]) 
開發者ID:depthsecurity,項目名稱:armory,代碼行數:19,代碼來源:armory.py

示例4: start

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def start(self, run_args=None):
        """ Starts a command and registers single handlers.

        Args:
            run_args (:class:`list`): the list of run arguments. If None we use sys.argv[1:].
        """
        if run_args is None:
            run_args = sys.argv[1:]

        parser = self._get_arg_parser()
        argcomplete.autocomplete(parser)

        if self.parse_unknown_args:
            args, unknown = parser.parse_known_args(run_args)
            self.run(args, unknown)
        else:
            args = parser.parse_args(run_args)
            self.run(args, {}) 
開發者ID:robbert-harms,項目名稱:MDT,代碼行數:20,代碼來源:shell_utils.py

示例5: _create_shell

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def _create_shell(crate_hosts, error_trace, output_writer, is_tty, args,
                  timeout=None, password=None):
    return CrateShell(crate_hosts,
                      error_trace=error_trace,
                      output_writer=output_writer,
                      is_tty=is_tty,
                      autocomplete=args.autocomplete,
                      autocapitalize=args.autocapitalize,
                      verify_ssl=args.verify_ssl,
                      cert_file=args.cert_file,
                      key_file=args.key_file,
                      ca_cert_file=args.ca_cert_file,
                      username=args.username,
                      password=password,
                      schema=args.schema,
                      timeout=timeout) 
開發者ID:crate,項目名稱:crash,代碼行數:18,代碼來源:command.py

示例6: parse_commands

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def parse_commands(argv):
    """
    parse the input command
    """
    # 首先創建一個ArgumentParser對象
    parser = argparse.ArgumentParser(description="FISCO BCOS 2.0 lite client @python")
    parsed_args = argparse.Namespace()
    cmd = parser.add_argument("cmd", nargs="+", help="the command for console")  # 添加參數
    cmd.completer = completion

    argcomplete.autocomplete(parser)
    args = parser.parse_args()

    print("\nINFO >> user input : {}\n".format(args.cmd))
    cmd = args.cmd[0]
    inputparams = args.cmd[1:]
    return cmd, inputparams 
開發者ID:FISCO-BCOS,項目名稱:python-sdk,代碼行數:19,代碼來源:console.py

示例7: __call__

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def __call__(self, args=None):
        if args is None:
            args = sys.argv[1:]
        if argcomplete:
            argcomplete.autocomplete(self.parser, exclude=['-P'])
        elif 'COMP_LINE' in os.environ:
            return 0
        sys.excepthook = self.handle
        args = self.read_configuration(args)
        args = self.parser.parse_args(args)
        self.configure_logging(args)
        if args.debug:
            try:
                import pudb
            except ImportError:
                pudb = None
                import pdb
            return (pudb or pdb).runcall(self.main, args)
        else:
            return self.main(args) or 0 
開發者ID:waveform-computing,項目名稱:compoundpi,代碼行數:22,代碼來源:terminal.py

示例8: main

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def main():
    try:
        argv = sys.argv[1:]
        conf   = Config()
        parser = arguments.get_root_parser(conf)
        argcomplete.autocomplete(parser)

        try:
            args = parser.parse_args(argv)
        except TypeError:
            args = parser.parse_args(argv + ["-h"])

        getattr(args.cmd(conf, args), args.fn)()
    except Exception as e:
        if (sys.argv[1] == "--print-traceback"):
            raise
        else:
            print("Error:", e)
            print("If you want to see full Traceback then run:")
            print("snet --print-traceback [parameters]")
            sys.exit(42) 
開發者ID:singnet,項目名稱:snet-cli,代碼行數:23,代碼來源:__init__.py

示例9: main

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def main():
  parser = argparse.ArgumentParser(description=__doc__)
  setup_argparse(parser)
  try:
    import argcomplete
    argcomplete.autocomplete(parser)
  except ImportError:
    pass
  args = parser.parse_args()

  thisdir = os.path.abspath(os.path.dirname(__file__))
  jenv = jinja2.Environment(
      loader=jinja2.FileSystemLoader(thisdir)
  )

  if args.command == "properties":
    get_properties(args, jenv)
  elif args.command == "variables":
    get_variables(args, jenv)
  elif args.command == "usages":
    cmd_get_usages(args, jenv)
  elif args.command == "deprecated":
    cmd_print_deprecated(args, jenv)
  else:
    logger.warning("Unknown command %s", args.command) 
開發者ID:cheshirekow,項目名稱:cmake_format,代碼行數:27,代碼來源:parse_cmake_help.py

示例10: parse_args

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def parse_args(self):
        """Parse the CLI args.
        """
        if self.args:
            self.log.debug('Warning: Arguments have already been parsed, ignoring duplicate attempt!')
            return

        argcomplete.autocomplete(self._arg_parser)

        self.acquire_lock()
        self.args = self._arg_parser.parse_args()

        if 'entrypoint' in self.args:
            self._entrypoint = self.args.entrypoint

        self.release_lock() 
開發者ID:qmk,項目名稱:qmk_cli,代碼行數:18,代碼來源:milc.py

示例11: m2cpp

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def m2cpp(args=None):
    """
    Execute main parser.

    Args:
        args (Optional[List[str]]):
            Argument to be parsed. If omitted, use ``sys.args``.
    """
    parser = create_parser()
    if argcomplete is not None:
        argcomplete.autocomplete(parser)

    args = parser.parse_args(args)

    from matlab2cpp.frontend import execute_parser
    execute_parser(args) 
開發者ID:jonathf,項目名稱:matlab2cpp,代碼行數:18,代碼來源:__init__.py

示例12: enable_autocomplete

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def enable_autocomplete(self, parser):
        if self.cli_ctx.data['completer_active']:
            argcomplete.autocomplete = argcomplete.CompletionFinder()
            argcomplete.autocomplete(parser, validator=lambda c, p: c.lower().startswith(p.lower()),
                                     default_completer=lambda _: ()) 
開發者ID:microsoft,項目名稱:knack,代碼行數:7,代碼來源:completion.py

示例13: parse_args

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def parse_args():
    parser = argparse.ArgumentParser(description=__doc__, epilog=_epilog)
    parser.add_argument(
        "--debug", action="store_true", help="include dump of all data returned"
    )
    parser.add_argument("--owners", action="store_true", help="Also show owners")
    parser.add_argument("--email", action="store_true", help="include owner email")
    parser.add_argument(
        "--all-my-orgs",
        action="store_true",
        help="act on all orgs for which you're an owner",
    )
    parser.add_argument(
        "--names-only",
        action="store_true",
        help="Only output your org names for which you're an owner",
    )
    parser.add_argument(
        "orgs", nargs="*", help="github organizations to check (defaults to " "mozilla)"
    )
    argcomplete.autocomplete(parser)
    args = parser.parse_args()
    if args.names_only:
        args.all_my_orgs = True
        if args.owners or args.email:
            parser.error("Can't specify owners or emails with --all-my-orgs")
    if args.all_my_orgs and len(args.orgs):
        parser.error("Can't specify orgs with --all-my-orgs")
    if args.email and not args.owners:
        # implies owners
        args.owners = True
    if args.debug:
        global DEBUG
        DEBUG = args.debug
    return args


# api.github.com/user/orgs endpoint not natively supported
# belongs in authenticated user 
開發者ID:mozilla,項目名稱:github-org-scripts,代碼行數:41,代碼來源:get_org_info.py

示例14: run_report

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def run_report(Report, argv, report):
    # Get the basic settings and database set up

    config = get_config_options()
    db = initialize_database(config)

    m = Report.Report(db)

    # Populate the options
    m.set_options()

    # A bunch of fun stuff to check if arguments provided on command line
    # and override config file if found.
    # module_config_data = get_config_options(module + '.ini')
    # if 'ModuleSettings' in module_config_data.sections():
    #     module_opt_keys = [a.option_strings for a in m.options._actions]
    #     for k in module_config_data['ModuleSettings'].keys():

    #         for o in module_opt_keys:

    #             if k in [a.replace('-', '') for a in o]:
    #                 exists = False
    #                 for n in o:
    #                     if n in argv:
    #                         exists = True
    #                 if not exists:

    #                     argv.append("--" + k)
    #                     argv.append(module_config_data['ModuleSettings'][k])

    argcomplete.autocomplete(m.options)
    args, unknown = m.options.parse_known_args(argv)
    m.base_config = config

    m.run(args) 
開發者ID:depthsecurity,項目名稱:armory,代碼行數:37,代碼來源:armory.py

示例15: parse_args

# 需要導入模塊: import argcomplete [as 別名]
# 或者: from argcomplete import autocomplete [as 別名]
def parse_args():
    parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description= \
        "Usage: python passmaker.py <OPTIONS> \n")

    menu_group = parser.add_argument_group('Menu Options')

    menu_group.add_argument('-o', '--output', help="password dict file", default=None)
    menu_group.add_argument('-i', '--interactive', help="interactive mode",action='store_true',default=False)
    menu_group.add_argument('-g', '--gui', help="GUI mode", action='store_true', default=False)

    argcomplete.autocomplete(parser)
    args = parser.parse_args()

    return args 
開發者ID:bit4woo,項目名稱:passmaker,代碼行數:16,代碼來源:passmaker.py


注:本文中的argcomplete.autocomplete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。