treeparse

argument

Positional argument definition.

argument

from __future__ import annotations

from treeparse import argument

arg = argument(
    name="path",
    arg_type=str,
    help="Input file or directory.",
    nargs=None,          # None=required, "?" optional, "*" / "+"
    default=None,
    choices=None,
    show_type=True,
    sort_key=0,
)

Rendering rules (help text)

  • nargs=None → <PATH>
  • nargs="?" → [PATH]
  • nargs="*" or "+" → [PATH ...]
  • With default and show_defaults=True on the app → [PATH=default]

nargs and default interact the same way as Python's argparse.

On this page