Skip to content

Argument

Argument provides extended parsing and validation options.

Argument is always added inside an Annotated type and provides the following functionality:

  • Adding help lines to the output of the --help option.
  • Reading parameters from environment variables.
  • Adding validation options for parsed pathlib.Path
  • Modifying the accepted datetime.datetime for the CLI.

Parameters:

Name Type Description Default
help str | None

The help string that will be presented by the CLI help.

None
envvar str | None

If supplied we will try to get the value of the parameter from the environment variable being pointed at.

None
exists bool

If True argument parsing will file if the path provided corresponds to a non-existent file or directory.

False
file_okay bool

If False argument parsing will file if the path provided corresponds to a file.

True
dir_okay bool

If False argument parsing will file if the path provided corresponds to a directory.

True
writable bool

Fail argument parsing if the path doesn't correspond to a writable file or directory.

False
readable bool

Fail argument parsing if the path doesn't correspond to a readable file or directory.

False
resolve_path bool

Whether to resolve the path supplied before passing it to the function.

False
formats list[str] | None

A list of format strings that can be used in the CLI to enter timestamps

None