Command Line Arguments

While writing some sanity checks, examples, and tests, the same ArgumentParser options kept coming up. This module organizes them and provides ArgumentParser, which inherits from the standard library’s object but adds some default flags.

tdg.cli.defaults()[source]

Provides a list of standard-library ArgumentParser objects.

Currently provides defaults from

class tdg.cli.ArgumentParser(*args, **kwargs)[source]

Bases: ArgumentParser

Forwards all arguments, except that it adds defaults() to the parents option.

Parameters
  • *args – Forwarded to the standard library’s ArgumentParser.

  • *kwargs – Forwarded to the standard library’s ArgumentParser.

parse_args(args=None, namespace=None)[source]

Forwards to the standard library but logs all the parsed values at the DEBUG level.

We will not provide details in this documentation about how these are implemented, though the source is commented.

tdg.cli.log.defaults()[source]

Returns an ArgumentParser which includes

  • --log-level

  • --log-format

When parsed, even with the default arguments, these options trigger a call to logging.basicConfig. If you want to manually control the logging setup you can override the created configuration by specifying force=True.

tdg.cli.metadata.defaults()[source]

Returns an ArgumentParser which includes

  • --version

  • --copyright

  • --license

These options print some information about tdg itself and then cause the program to exit.