argclz.core.Argument#

class argclz.core.Argument[source]#

Bases: object

(internal) Do not use class directly.

Commandline argument descriptor (https://docs.python.org/3/glossary.html#term-descriptor). Carried the arguments pass to argparse.ArgumentParser.add_argument.

__init__(*options, validator=None, group=None, ex_group=None, hidden=False, **kwargs)[source]#
Parameters:
  • options – options

  • validator (Callable[[T], bool] | None) – argument validator.

  • group (str | None) – argument group.

  • ex_group (str | None) – mutually exclusive group.

  • hidden (bool) – hide this argument from help document

  • kwargs

Methods Summary

__init__(*options[, validator, group, ...])

add_argument(ap, instance)

Add this into argparse.ArgumentParser.

with_options(*options, **kwargs)

Modify or update keyword parameter and return a new argument.

Attributes Summary

Details

property default#
property const#
property metavar: str | None#
property choices: tuple[Any, ...] | None#
property required: bool#
property type: type | Callable[[str], Any] | None#
property help: str | None#
add_argument(ap, instance)[source]#

Add this into argparse.ArgumentParser.

Parameters:
  • ap (_ActionsContainer)

  • instance

Returns:

with_options(*options, **kwargs)[source]#

Modify or update keyword parameter and return a new argument.

option flags update rule:

  1. (), (...) : do not update options

  2. ('-a', '-b') : replace options

  3. (..., '-c') : additional options

  4. ({'-a': '-A'}) : rename options

  5. ({'-a': ...}) : remove options

  6. ({'-a': '-A', '-b': ...}, '-c') : rename ‘-a’, remove ‘-b’, add ‘-c’

general form:

() | (dict?, ...?, *str)

Parameters:
  • options – change option flags

  • kwargs – change keyword parameters, use to unset parameter

Returns:

Return type:

Self