Python argparse.SUPPRESS Examples

The following are 40 code examples for showing how to use argparse.SUPPRESS(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module argparse , or try the search function .

Example 1
Project: aegea   Author: kislyuk   File: batch.py    License: Apache License 2.0 6 votes vote down vote up
def add_command_args(parser):
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--watch", action="store_true", help="Monitor submitted job, stream log until job completes")
    group.add_argument("--wait", action="store_true",
                       help="Block on job. Exit with code 0 if job succeeded, 1 if failed")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--command", nargs="+", help="Run these commands as the job (using " + BOLD("bash -c") + ")")
    group.add_argument("--execute", type=argparse.FileType("rb"), metavar="EXECUTABLE",
                       help="Read this executable file and run it as the job")
    group.add_argument("--wdl", type=argparse.FileType("rb"), metavar="WDL_WORKFLOW",
                       help="Read this WDL workflow file and run it as the job")
    parser.add_argument("--wdl-input", type=argparse.FileType("r"), metavar="WDL_INPUT_JSON", default=sys.stdin,
                        help="With --wdl, use this JSON file as the WDL job input (default: stdin)")
    parser.add_argument("--environment", nargs="+", metavar="NAME=VALUE",
                        type=lambda x: dict(zip(["name", "value"], x.split("=", 1))), default=[])
    parser.add_argument("--staging-s3-bucket", help=argparse.SUPPRESS) 
Example 2
Project: calmjs   Author: calmjs   File: runtime.py    License: GNU General Public License v2.0 6 votes vote down vote up
def init_argparser_source_registry(
            self, argparser, default=None, help=(
                'comma separated list of registries to use for gathering '
                'JavaScript sources from the given Python packages'
            )):
        """
        For setting up the source registry flag.
        """

        argparser.add_argument(
            '--source-registry', default=default,
            dest=CALMJS_MODULE_REGISTRY_NAMES, action=StoreDelimitedList,
            metavar='<registry>[,<registry>[...]]',
            help=help,
        )

        argparser.add_argument(
            '--source-registries', default=default,
            dest=CALMJS_MODULE_REGISTRY_NAMES, action=StoreDelimitedList,
            help=SUPPRESS,
        ) 
Example 3
Project: mx   Author: graalvm   File: mx_benchmark.py    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, vm_type_name, short_vm_type_name=None, default_vm=None, known_host_registries=None):
        """

        :param str vm_type_name: full VM type name (e.g., "Java")
        :param str short_vm_type_name:
        :param default_vm: a callable which, given a config name gives a default VM name
        :param list[VmRegistry] known_host_registries: a list of known host VM registries
        """
        self.vm_type_name = vm_type_name + " VM"
        self.short_vm_type_name = short_vm_type_name if short_vm_type_name else vm_type_name.lower() + "-vm"
        assert default_vm is None or callable(default_vm)
        self.default_vm = default_vm
        assert re.compile(r"\A[a-z-]+\Z").match(self.short_vm_type_name)
        self._vms = OrderedDict()
        self._vms_suite = {}
        self._vms_priority = {}
        self._known_host_registries = known_host_registries or []
        add_parser(self.get_parser_name(), ParserEntry(
            ArgumentParser(add_help=False, usage=_mx_benchmark_usage_example + " -- <options> -- ..."),
            "\n\n{} selection flags, specified in the benchmark suite arguments:\n".format(self.vm_type_name)
        ))
        get_parser(self.get_parser_name()).add_argument("--{}".format(self.short_vm_type_name), default=None, help="{vm} to run the benchmark with.".format(vm=self.vm_type_name))
        get_parser(self.get_parser_name()).add_argument("--{}-config".format(self.short_vm_type_name), default=None, help="{vm} configuration for the selected {vm}.".format(vm=self.vm_type_name))
        # Separator to stack guest and host VM options. Though ignored, must be consumed by the parser.
        get_parser(self.get_parser_name()).add_argument('--guest', action='store_true', dest=SUPPRESS, default=None, help='Separator for --{vm}=host --guest --{vm}=guest VM configurations.'.format(vm=self.short_vm_type_name)) 
Example 4
Project: qutebrowser   Author: qutebrowser   File: src2asciidoc.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _format_action(action):
    """Get an invocation string/help from an argparse action."""
    if action.help == argparse.SUPPRESS:
        return None
    if not action.option_strings:
        invocation = '*{}*::'.format(_get_action_metavar(action))
    else:
        parts = []
        if action.nargs == 0:
            # Doesn't take a value, so the syntax is -s, --long
            parts += ['*{}*'.format(s) for s in action.option_strings]
        else:
            # Takes a value, so the syntax is -s ARGS or --long ARGS.
            args_string = _format_action_args(action)
            for opt in action.option_strings:
                parts.append('*{}* {}'.format(opt, args_string))
        invocation = ', '.join(parts) + '::'
    return '{}\n    {}\n'.format(invocation, action.help) 
Example 5
Project: jbox   Author: jpush   File: config.py    License: MIT License 6 votes vote down vote up
def parser(self):
        kwargs = {
            "usage": self.usage,
            "prog": self.prog
        }
        parser = argparse.ArgumentParser(**kwargs)
        parser.add_argument("-v", "--version",
                action="version", default=argparse.SUPPRESS,
                version="%(prog)s (version " + __version__ + ")\n",
                help="show program's version number and exit")
        parser.add_argument("args", nargs="*", help=argparse.SUPPRESS)

        keys = sorted(self.settings, key=self.settings.__getitem__)
        for k in keys:
            self.settings[k].add_option(parser)

        return parser 
Example 6
Project: westpa   Author: westpa   File: w_ipa.py    License: MIT License 6 votes vote down vote up
def add_args(self, parser):
        self.progress.add_args(parser)
        self.data_reader.add_args(parser)
        rgroup = parser.add_argument_group('runtime options')
        rgroup.add_argument('--analysis-only', '-ao', dest='analysis_mode', action='store_true',
                             help='''Use this flag to run the analysis and return to the terminal.''')
        rgroup.add_argument('--reanalyze', '-ra', dest='reanalyze', action='store_true',
                             help='''Use this flag to delete the existing files and reanalyze.''')
        rgroup.add_argument('--ignore-hash', '-ih', dest='ignore_hash', action='store_true',
                             help='''Ignore hash and don't regenerate files.''')
        rgroup.add_argument('--debug', '-d', dest='debug_mode', action='store_true',
                             help='''Debug output largely intended for development.''')
        rgroup.add_argument('--terminal', '-t', dest='plotting', action='store_true',
                             help='''Plot output in terminal.''')
        # There is almost certainly a better way to handle this, but we'll sort that later.
        import argparse
        rgroup.add_argument('--f', '-f', dest='extra', default='blah',
                             help=argparse.SUPPRESS)
        
        parser.set_defaults(compression=True) 
Example 7
Project: ScoutSuite   Author: nccgroup   File: cli_parser.py    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        self.parser = argparse.ArgumentParser()

        # People will still be able to use the old --provider syntax
        self.parser.add_argument("--provider",
                                 action='store_true',
                                 dest='sinkhole',
                                 help=argparse.SUPPRESS)

        self.parser.add_argument('-v', '--version',
                                 action='version',
                                 version='Scout Suite {}'.format(__version__))

        self.common_providers_args_parser = argparse.ArgumentParser(add_help=False)

        self.subparsers = self.parser.add_subparsers(title="The provider you want to run scout against",
                                                     dest="provider")

        self._init_common_args_parser()

        self._init_aws_parser()
        self._init_gcp_parser()
        self._init_azure_parser()
        self._init_aliyun_parser()
        self._init_oci_parser() 
Example 8
Project: wifite2mod   Author: nuncan   File: args.py    License: GNU General Public License v2.0 6 votes vote down vote up
def get_arguments(self):
        ''' Returns parser.args() containing all program arguments '''

        parser = argparse.ArgumentParser(usage=argparse.SUPPRESS,
                formatter_class=lambda prog: argparse.HelpFormatter(
                    prog, max_help_position=80, width=130))

        self._add_global_args(parser.add_argument_group(Color.s('{C}SETTINGS{W}')))
        self._add_wep_args(parser.add_argument_group(Color.s('{C}WEP{W}')))
        self._add_wpa_args(parser.add_argument_group(Color.s('{C}WPA{W}')))
        self._add_wps_args(parser.add_argument_group(Color.s('{C}WPS{W}')))
        self._add_pmkid_args(parser.add_argument_group(Color.s('{C}PMKID{W}')))
        self._add_eviltwin_args(parser.add_argument_group(Color.s('{C}EVIL TWIN{W}')))
        self._add_command_args(parser.add_argument_group(Color.s('{C}COMMANDS{W}')))

        return parser.parse_args() 
Example 9
Project: wifite2mod   Author: nuncan   File: args.py    License: GNU General Public License v2.0 6 votes vote down vote up
def _add_pmkid_args(self, pmkid):
        pmkid.add_argument('--pmkid',
                         action='store_true',
                         dest='use_pmkid_only',
                         help=Color.s('{O}Only{W} use {C}PMKID capture{W}, avoids other WPS & ' +
                                      'WPA attacks (default: {G}off{W})'))
        pmkid.add_argument('--no-pmkid',
                         action='store_true',
                         dest='dont_use_pmkid',
                         help=Color.s('{O}Don\'t{W} use {C}PMKID capture{W} ' +
                                      '(default: {G}off{W})'))
        # Alias
        pmkid.add_argument('-pmkid', help=argparse.SUPPRESS, action='store_true', dest='use_pmkid_only')

        pmkid.add_argument('--pmkid-timeout',
                         action='store',
                         dest='pmkid_timeout',
                         metavar='[sec]',
                         type=int,
                         help=Color.s('Time to wait for PMKID capture ' +
                                      '(default: {G}%d{W} seconds)' % self.config.pmkid_timeout)) 
Example 10
Project: wifite2mod   Author: nuncan   File: args.py    License: GNU General Public License v2.0 6 votes vote down vote up
def _add_command_args(self, commands):
        commands.add_argument('--cracked',
            action='store_true',
            dest='cracked',
            help=Color.s('Print previously-cracked access points'))
        commands.add_argument('-cracked', help=argparse.SUPPRESS, action='store_true',
                dest='cracked')

        commands.add_argument('--check',
            action='store',
            metavar='file',
            nargs='?',
            const='<all>',
            dest='check_handshake',
            help=Color.s('Check a {C}.cap file{W} (or all {C}hs/*.cap{W} files) ' +
                'for WPA handshakes'))
        commands.add_argument('-check', help=argparse.SUPPRESS, action='store',
                nargs='?', const='<all>', dest='check_handshake')

        commands.add_argument('--crack',
            action='store_true',
            dest='crack_handshake',
            help=Color.s('Show commands to crack a captured handshake')) 
Example 11
Project: fairseq   Author: pytorch   File: registry.py    License: MIT License 6 votes vote down vote up
def set_defaults(args, cls):
    """Helper to set default arguments based on *add_args*."""
    if not hasattr(cls, 'add_args'):
        return
    parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS, allow_abbrev=False)
    cls.add_args(parser)
    # copied from argparse.py:
    defaults = argparse.Namespace()
    for action in parser._actions:
        if action.dest is not argparse.SUPPRESS:
            if not hasattr(defaults, action.dest):
                if action.default is not argparse.SUPPRESS:
                    setattr(defaults, action.dest, action.default)
    for key, default_value in vars(defaults).items():
        if not hasattr(args, key):
            setattr(args, key, default_value) 
Example 12
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: curses_ui_test.py    License: MIT License 6 votes vote down vote up
def _print_ones(self, args, screen_info=None):
    ap = argparse.ArgumentParser(
        description="Print all-one matrix.", usage=argparse.SUPPRESS)
    ap.add_argument(
        "-s",
        "--size",
        dest="size",
        type=int,
        default=3,
        help="Size of the matrix. For example, of the value is 3, "
        "the matrix will have shape (3, 3)")

    parsed = ap.parse_args(args)

    m = np.ones([parsed.size, parsed.size])

    return tensor_format.format_tensor(m, "m") 
Example 13
Project: ngraph-python   Author: NervanaSystems   File: flexargparser.py    License: Apache License 2.0 6 votes vote down vote up
def setup_flex_args(argParser):
        """
        Add flex specific arguments to other default args used by ngraph
        """
        # use fixed point for flex backend
        argParser.add_argument('--fixed_point',
                               action="store_true",
                               help=argparse.SUPPRESS)
        # turn on flex verbosity for debug
        argParser.add_argument('--flex_verbose',
                               action="store_true",
                               help=argparse.SUPPRESS)
        # collect flex data and save it to h5py File
        argParser.add_argument('--collect_flex_data',
                               action="store_true",
                               default=argparse.SUPPRESS) 
Example 14
Project: grimoirelab-sirmordred   Author: chaoss   File: panels_config.py    License: GNU General Public License v3.0 6 votes vote down vote up
def get_params_parser():
    """Parse command line arguments"""

    parser = argparse.ArgumentParser(add_help=False)

    parser.add_argument('-g', '--debug', dest='debug',
                        action='store_true',
                        help=argparse.SUPPRESS)

    parser.add_argument("--cfg", dest='cfg_path',
                        help="Configuration file path")
    parser.add_argument("--dashboards", action='store_true', dest='dashboards',
                        help="Upload dashboards")
    parser.add_argument("--menu", action='store_true', dest='menu',
                        help="Upload menu")

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    return parser 
Example 15
Project: aegea   Author: kislyuk   File: ssh.py    License: Apache License 2.0 5 votes vote down vote up
def add_bless_and_passthrough_opts(parser, program):
    parser.add_argument("--bless-config", default=os.environ.get("BLESS_CONFIG"),
                        help="Path to a Bless configuration file (or pass via the BLESS_CONFIG environment variable)")
    parser.add_argument("--use-kms-auth", help=argparse.SUPPRESS)
    for opt in opts_by_nargs[program][0]:
        parser.add_argument("-" + opt, action="store_true", help=argparse.SUPPRESS)
    for opt in opts_by_nargs[program][1]:
        parser.add_argument("-" + opt, action="append", help=argparse.SUPPRESS) 
Example 16
Project: calmjs   Author: calmjs   File: argparse.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, original_action_cls, deprecation, *a, **kw):
        self.original_action = original_action_cls(*a, **kw)
        # copy the kwargs from within to ensure API compatibility and
        # expectations
        kw.update(self.original_action._get_kwargs())
        # only set message if it's a string.
        self.deprecation = '' if deprecation is True else deprecation
        kw['help'] = argparse.SUPPRESS
        super(DeprecatedAction, self).__init__(*a, **kw) 
Example 17
Project: calmjs   Author: calmjs   File: runtime.py    License: GNU General Public License v2.0 5 votes vote down vote up
def init_argparser(self, argparser):
        self.global_opts = argparser.add_argument_group('global options')
        self.global_opts.add_argument(
            '-d', '--debug', action='count', default=0,
            help="show traceback on error; twice for post_mortem '--debugger' "
                 "when execution cannot continue")
        self.global_opts.add_argument(
            '--debugger', action='store_const', const=2, dest='debug',
            help=SUPPRESS)
        self.global_opts.add_argument(
            '-q', '--quiet', action='count', default=0,
            help="be more quiet")
        self.global_opts.add_argument(
            '-v', '--verbose', action='count', default=0,
            help="be more verbose") 
Example 18
Project: telegram-messages-dump   Author: Kosat   File: chat_dump_settings.py    License: MIT License 5 votes vote down vote up
def add_usage(self, usage, actions, groups, prefix=None):
        if usage is not argparse.SUPPRESS:
            args = usage, actions, groups, ''
            self._add_item(self._format_usage, args) 
Example 19
Project: Rebaler   Author: rrwick   File: misc.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _get_help_string(self, action):
        help_text = action.help
        if action.default != argparse.SUPPRESS and 'default' not in help_text.lower() and \
                action.default is not None:
            help_text += ' (default: ' + str(action.default) + ')'
        return help_text 
Example 20
Project: VxAPI   Author: PayloadSecurity   File: default_cli_arguments.py    License: GNU General Public License v3.0 5 votes vote down vote up
def add_help_opt(self):
        self.parser.add_argument('--help', '-h', action='help', default=argparse.SUPPRESS, help='Show this help message and exit.')

        return self 
Example 21
Project: pysploit-framework   Author: ahmadnourallah   File: PySploit.py    License: GNU General Public License v2.0 5 votes vote down vote up
def main():
    parser = ArgumentParser(prog='PySploit',usage='python3 PySploit.py [options]',  add_help=False)
    help_arguments = parser.add_argument_group('help arguments')
    help_arguments.add_argument('-v', '--version', action='version', version="version 1.2")
    help_arguments.add_argument('-h', '--help', action='help', default=SUPPRESS, help='show this help message and exit.')
    optional_arguments = parser.add_argument_group('optional arguments')
    optional_arguments.add_argument('-c', '--create', dest='filename', required=False, help='create module sample')
    optional_arguments.add_argument('-u', '--upgrade', required=False, action='store_true',  help='create module sample')
    optional_arguments.add_argument('-m', '--manual', required=False, action='store_true',  help='show tool man page')
    optional_arguments.add_argument('-i', '--install', required=False, action='store_true',  help='install tool on your computer')
    optional_arguments.add_argument('-un', '--uninstall', required=False, action='store_true',  help='uninstall tool from your computer')
    args = parser.parse_args()
    if len(argv) > 1:
        if args.filename is not None:
            filename = open(args.filename, 'w')
            filename.write(sample)
        elif args.upgrade == True:
            interpreter().check_upgrade()
        elif args.manual == True:
            try:
                check_call('man /etc/pysploit-framework/docs/pysploit',shell=True)
            except CalledProcessError:
                print(red('\n[!]') + green(' Tool') + " manual is not installed yet\n")
        elif args.install == True:
            install()
        elif args.uninstall == True:
            uninstall()
    else:
        Banner()
        while True:
            interpreter().start_interpreter() 
Example 22
Project: qutebrowser   Author: qutebrowser   File: mkvenv.py    License: GNU General Public License v3.0 5 votes vote down vote up
def parse_args() -> argparse.Namespace:
    """Parse commandline arguments."""
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--keep',
                        action='store_true',
                        help="Reuse an existing virtualenv.")
    parser.add_argument('--venv-dir',
                        default='.venv',
                        help="Where to place the virtualenv.")
    parser.add_argument('--pyqt-version',
                        choices=pyqt_versions(),
                        default='auto',
                        help="PyQt version to install.")
    parser.add_argument('--pyqt-type',
                        choices=['binary', 'source', 'link', 'wheels', 'skip'],
                        default='binary',
                        help="How to install PyQt/Qt.")
    parser.add_argument('--pyqt-wheels-dir',
                        default='wheels',
                        help="Directory to get PyQt wheels from.")
    parser.add_argument('--virtualenv',
                        action='store_true',
                        help="Use virtualenv instead of venv.")
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--dev',
                        action='store_true',
                        help="Also install dev/test dependencies.")
    parser.add_argument('--skip-docs',
                        action='store_true',
                        help="Skip doc generation.")
    parser.add_argument('--tox-error',
                        action='store_true',
                        help=argparse.SUPPRESS)
    return parser.parse_args() 
Example 23
Project: pyspelling   Author: facelessuser   File: __main__.py    License: MIT License 5 votes vote down vote up
def main():
    """Main."""

    parser = argparse.ArgumentParser(prog='spellcheck', description='Spell checking tool.')
    # Flag arguments
    parser.add_argument('--version', action='version', version=('%(prog)s ' + __version__))
    parser.add_argument('--debug', action='store_true', default=False, help=argparse.SUPPRESS)
    parser.add_argument('--verbose', '-v', action='count', default=0, help="Verbosity level.")
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--name', '-n', action='append', help="Specific spelling task by name to run.")
    group.add_argument('--group', '-g', action='append', help="Specific spelling task groun to run.")
    parser.add_argument('--binary', '-b', action='store', default='', help="Provide path to spell checker's binary.")
    parser.add_argument('--config', '-c', action='store', default='', help="Spelling config.")
    parser.add_argument('--source', '-S', action='append', help="Specify override file pattern.")
    parser.add_argument(
        '--spellchecker', '-s', action='store', default='', help="Choose between aspell and hunspell"
    )
    args = parser.parse_args()

    return run(
        args.config,
        names=args.name,
        groups=args.group,
        binary=args.binary,
        spellchecker=args.spellchecker,
        sources=args.source,
        verbose=args.verbose,
        debug=args.debug
    ) 
Example 24
Project: video-caption-openNMT.pytorch   Author: xiadingZ   File: opts.py    License: MIT License 5 votes vote down vote up
def __init__(self, option_strings,
                 dest=argparse.SUPPRESS, default=argparse.SUPPRESS,
                 **kwargs):
        super(MarkdownHelpAction, self).__init__(
            option_strings=option_strings,
            dest=dest,
            default=default,
            nargs=0,
            **kwargs) 
Example 25
Project: knack   Author: microsoft   File: help.py    License: MIT License 5 votes vote down vote up
def __init__(self, help_ctx, delimiters, parser):

        super(CommandHelpFile, self).__init__(help_ctx, delimiters)
        self.type = 'command'

        self.parameters = []

        for action in [a for a in parser._actions if a.help != argparse.SUPPRESS]:  # pylint: disable=protected-access
            if action.option_strings:
                self._add_parameter_help(action)
            else:
                # use metavar for positional parameters
                param_kwargs = {
                    'name_source': [action.metavar or action.dest],
                    'deprecate_info': getattr(action, 'deprecate_info', None),
                    'preview_info': getattr(action, 'preview_info', None),
                    'experimental_info': getattr(action, 'experimental_info', None),
                    'description': action.help,
                    'choices': action.choices,
                    'required': False,
                    'default': None,
                    'group_name': 'Positional'
                }
                self.parameters.append(HelpParameter(**param_kwargs))

        help_param = next(p for p in self.parameters if p.name == '--help -h')
        help_param.group_name = 'Global Arguments' 
Example 26
Project: knack   Author: microsoft   File: help.py    License: MIT License 5 votes vote down vote up
def _get_choices_defaults_sources_str(p):
        choice_str = u'  Allowed values: {}.'.format(', '.join(sorted([str(x) for x in p.choices]))) \
            if p.choices else ''
        default_str = u'  Default: {}.'.format(p.default) \
            if p.default and p.default != argparse.SUPPRESS else ''
        value_sources_str = u'  Values from: {}.'.format(', '.join(p.value_sources)) \
            if p.value_sources else ''
        return u'{}{}{}'.format(choice_str, default_str, value_sources_str) 
Example 27
Project: uxy   Author: sustrik   File: uxy_w.py    License: MIT License 5 votes vote down vote up
def _linux_args(args):
  parser = argparse.ArgumentParser("__main__.py w", add_help=False)
  parser.add_argument("-h", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("--no-header", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("-s", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("--short", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("-f", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("--from", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("-o", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("--old-style", action="store_true", default=argparse.SUPPRESS)
  parser.add_argument("--help", action="store_true", default=argparse.SUPPRESS)
  base.check_args(args, parser)
  return args + [] 
Example 28
Project: uxy   Author: sustrik   File: uxy_w.py    License: MIT License 5 votes vote down vote up
def _osx_args(args):
  parser = argparse.ArgumentParser("__main__.py w", add_help=False)
  parser.add_argument("-h", action="store_true", default=argparse.SUPPRESS)
  base.check_args(args, parser)
  return args + [] 
Example 29
Project: jbox   Author: jpush   File: __init__.py    License: MIT License 5 votes vote down vote up
def add_help(parser, help_args): 
    if not help_args:
        return
    parser.add_argument(*help_args,
                        action='help', default=argparse.SUPPRESS, help=_('show this help message and exit')) 
Example 30
Project: wikicurses   Author: ids1024   File: main.py    License: MIT License 5 votes vote down vote up
def main():
    parser = argparse.ArgumentParser(
        description="A simple curses interface for accessing Wikipedia.")

    parser.add_argument('search',
                        nargs='?',
                        help="page to search for")
    parser.add_argument('-w', '--wiki', help='wiki api url')
    # For shell completion functions
    parser.add_argument('--complete',
                        action='store',
                        help=argparse.SUPPRESS)
    parser.add_argument('--dumpcolors',
                        action='store_true',
                        help="print default color settings")

    parser.add_argument('-f', '--feed', help='view featured feed')

    args = parser.parse_args()
    openWiki(args.wiki)

    if args.complete:
        if args.complete == 'search':
            sugestions = wiki.search_sugestions(args.search)
        elif args.complete == 'feed':
            sugestions = wiki.list_featured_feeds()
        elif args.complete == 'wiki':
            sugestions = settings.wikis().keys()
        print(*sugestions, sep='\n')
        return
    elif args.dumpcolors:
        settings.dumpColors()
        print("Color settings written to " + settings.colorspath + '.')
        return

    callback = lambda x, y: openPage(args.feed or args.search, bool(args.feed))
    loop.set_alarm_in(.001, callback)  # Open page once loop is started
    try:
        loop.run()
    except KeyboardInterrupt:
        pass 
Example 31
Project: ChromaTerm   Author: hSaria   File: cli.py    License: MIT License 5 votes vote down vote up
def args_init(args=None):
    """Returns the parsed arguments (an instance of argparse.Namespace).

    Args:
        args (list): A list of program arguments, Defaults to sys.argv.
    """
    parser = argparse.ArgumentParser()

    parser.add_argument('program',
                        type=str,
                        metavar='program ...',
                        nargs='?',
                        help='run a program with anything after it used as '
                        'arguments')

    parser.add_argument('arguments',
                        type=str,
                        nargs=argparse.REMAINDER,
                        help=argparse.SUPPRESS,
                        default=[])

    parser.add_argument('--config',
                        metavar='FILE',
                        type=str,
                        help='location of config file (default: %(default)s)',
                        default='$HOME/.chromaterm.yml')

    parser.add_argument('--reload',
                        action='store_true',
                        help='Reload the config of all CT instances')

    parser.add_argument('--rgb',
                        action='store_true',
                        help='Use RGB colors (default: detect support, '
                        'fallback to xterm-256)',
                        default=None)

    return parser.parse_args(args=args) 
Example 32
Project: rekall   Author: google   File: args.py    License: GNU General Public License v2.0 5 votes vote down vote up
def add_argument(self, action):
        # Allow us to suppress an arg from the --help output for those options
        # which do not make sense on the command line.
        if action.dest != "SUPPRESS":
            super(RekallHelpFormatter, self).add_argument(action) 
Example 33
Project: mars   Author: mars-project   File: __main__.py    License: Apache License 2.0 5 votes vote down vote up
def config_args(self, parser):
        parser.add_argument('--cpu-procs', help='number of processes used for cpu')
        parser.add_argument('--cuda-device', help='CUDA device to use, if not specified, will '
                                                  'use CPU only')
        parser.add_argument('--net-procs', help='number of processes used for networking')
        parser.add_argument('--io-procs', help=argparse.SUPPRESS,
                            action=arg_deprecated_action('--net-procs'))
        parser.add_argument('--phy-mem', help='physical memory size limit')
        parser.add_argument('--ignore-avail-mem', action='store_true', help='ignore available memory')
        parser.add_argument('--cache-mem', help='cache memory size limit')
        parser.add_argument('--min-mem', help='minimal free memory required to start worker')
        parser.add_argument('--spill-dir', help='spill directory')
        parser.add_argument('--lock-free-fileio', action='store_true',
                            help='make file io lock free, add this when using a mounted dfs')
        parser.add_argument('--plasma-dir', help='path of plasma directory. When specified, the size '
                                                 'of plasma store will not be taken into account when '
                                                 'managing host memory')

        compress_types = ', '.join(v.value for v in CompressType.__members__.values())
        parser.add_argument('--disk-compression',
                            default=options.worker.disk_compression,
                            help='compression type used for disks, '
                                 'can be selected from %s. %s by default'
                                 % (compress_types, options.worker.disk_compression))
        parser.add_argument('--transfer-compression',
                            default=options.worker.transfer_compression,
                            help='compression type used for network transfer, '
                                 'can be selected from %s. %s by default'
                                 % (compress_types, options.worker.transfer_compression)) 
Example 34
Project: Abeebus   Author: 13Cubed   File: abeebus.py    License: MIT License 5 votes vote down vote up
def main():
  parser = argparse.ArgumentParser(description='Abeebus - A GeoIP lookup utility utilizing ipinfo.io services.', usage='abeebus.py filename(s) [-w outfile] [-s]', add_help=False)
  parser.add_argument('filenames', nargs="*")
  parser.add_argument('-w', '--write', help='Write output to CSV file instead of stdout', required=False)
  parser.add_argument('-s', '--sort-by-count', action='store_true', help='Sort addresses by count (descending)', required=False)
  parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS, help='Show this help message and exit')
  args = vars(parser.parse_args())

  # Make sure at least one filename was provided
  if not (args['filenames']):
    parser.print_usage()
    parser.exit()

  filenames = args['filenames']
  writeToFile = 0
  sortByCount = 0

  if (args['write']):
    writeToFile = 1
    outfile = args['write']

  if (args['sort_by_count']):
    sortByCount = 1

  output = getData(filenames,sortByCount)

  if (writeToFile == 1):
    writeData(output,outfile)

  else:
    printData(output)

  print ('\nCopyright (C) 2018 13Cubed. All rights reserved.') 
Example 35
Project: fastchess   Author: thomasahle   File: tune.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _get_help_string(self, action):
        help = action.help
        if not action.default:
            return help
        if '%(default)' not in action.help:
            if action.default is not argparse.SUPPRESS:
                defaulting_nargs = [argparse.OPTIONAL, argparse.ZERO_OR_MORE]
                if action.option_strings or action.nargs in defaulting_nargs:
                    help += ' (default: %(default)s)'
        return help 
Example 36
Project: ironpython2   Author: IronLanguages   File: test_argparse.py    License: Apache License 2.0 5 votes vote down vote up
def get_parser(self, required):
        parser = ErrorRaisingArgumentParser(prog='PROG')
        group = parser.add_mutually_exclusive_group(required=required)
        group.add_argument('-x', help=argparse.SUPPRESS)
        group.add_argument('-y', action='store_false', help='y help')
        return parser 
Example 37
Project: ironpython2   Author: IronLanguages   File: test_argparse.py    License: Apache License 2.0 5 votes vote down vote up
def get_parser(self, required):
        parser = ErrorRaisingArgumentParser(prog='PROG')
        group = parser.add_mutually_exclusive_group(required=required)
        add = group.add_argument
        add('--spam', action='store_true', help=argparse.SUPPRESS)
        add('--badger', action='store_false', help=argparse.SUPPRESS)
        add('--bladder', help=argparse.SUPPRESS)
        return parser 
Example 38
Project: appr   Author: app-registry   File: command_base.py    License: Apache License 2.0 5 votes vote down vote up
def _add_registryhost_option(cls, parser):
        parser.add_argument("-H", "--registry-host", default=None, help=argparse.SUPPRESS)
        parser.add_argument("-k", "--insecure", action="store_true", default=False,
                            help="turn off verification of the https certificate")
        parser.add_argument("--cacert", default=None,
                            help="CA certificate to verify peer against (SSL)") 
Example 39
Project: appr   Author: app-registry   File: jsonnet.py    License: Apache License 2.0 5 votes vote down vote up
def _add_arguments(cls, parser):
        parser.add_argument("--namespace", help="kubernetes namespace", default='default')
        parser.add_argument("-x", "--variables", help="variables", default={},
                            action=LoadVariables)
        parser.add_argument('filepath', nargs=1, help="Fetch package from the registry")
        parser.add_argument('--raw', action="store_true", default=False, help=argparse.SUPPRESS)
        parser.add_argument('-J', '--lib-dir', action='append', default=[],
                            help="Specify an additional library search dir") 
Example 40
Project: appr   Author: app-registry   File: push.py    License: Apache License 2.0 5 votes vote down vote up
def _add_arguments(cls, parser):
        cls._add_registryhost_option(parser)
        cls._add_mediatype_option(parser, cls.default_media_type, required=False)
        cls._add_packageversion_option(parser)
        parser.add_argument("--ns", "--namespace", default=None, help=argparse.SUPPRESS)
        parser.add_argument("-f", "--force", action='store_true', default=False, help="force push")
        parser.add_argument("-c", "--channel", default=None, help="Set a channel")
        parser.add_argument("--version-parts", default={}, help=argparse.SUPPRESS)
        parser.add_argument("--package-parts", default={}, help=argparse.SUPPRESS)
        parser.add_argument('package', nargs='?', default=None, action=PackageSplit,
                            help="repository dest")