microprobe.utils.cmdline.CLI

class CLI(description, **kwargs)[source]

Bases: object

Object to define a Command Line Interface.

__init__(description, **kwargs)[source]

Create a new command line parser.

Methods

__init__(description, **kwargs)

Create a new command line parser.

add_description(text)

Add more text to the description.

add_epilog(text)

Add an epilog to the help message.

add_flag(name, short, descr[, group, configfile])

Add a boolean flag.

add_group(name, description)

Add an option group.

add_option(name, short, default, descr[, ...])

Add an option that takes an argument.

get(name)

param name:

main(options, main, *args, **kwargs)

Main wrapper with common error control.

save(filename[, full])

param filename:

Attributes

arg_parser

arguments

Dictionary mapping arguments to values.




property arg_parser
property arguments

Dictionary mapping arguments to values.

add_description(text)[source]

Add more text to the description.

Parameters:

text (str) – Additional description text.

add_epilog(text)[source]

Add an epilog to the help message.

Parameters:

text (str) – Additional description text.

add_group(name, description)[source]

Add an option group.

Allows the organization of options into groups.

Parameters:
  • name (str) – Name of the group.

  • description (str) – Short description. This is shown in the extended help.

add_flag(name, short, descr, group=None, configfile=True)[source]

Add a boolean flag.

Parameters:
  • name (str) – Name of the option.

  • short (str or None) – Single-char name of the option.

  • descr (str) – Description of the option.

  • group (str) – Name of the option group of this option.

add_option(name, short, default, descr, opt_type=<class 'str'>, action=None, choices=None, group=None, metavar=None, required=False, nargs=None, configfile=True)[source]

Add an option that takes an argument.

See argparse for extended help.

Parameters:
  • name (str or None) – Name of the option. If None, uses short as the name for get().

  • short (str or None) – Single-char name of the option.

  • default – Default value.

  • descr (str) – Description of the option.

  • type – Option type (see python’s argparse documentation).

  • action – Action when flag is given (see python’s argparse documentation).

  • choices – Valid option values if type is choice.

  • group (str) – Name of the option group of this option.

You cannot have both name and short with a None value.

get(name)[source]
Parameters:

name

main(options, main, *args, **kwargs)[source]

Main wrapper with common error control.

Parses command line options and then calls main.

Parameters:
  • options (list of str) – Command line options.

  • main (callable) – User-defined main function.

  • implicit (str) – Option string to prepend when executing from script header (hash-bang syntax).

  • skip (callable) – When given, skip stack trace until the given function.

  • args – Extra arguments to main.

save(filename, full=False)[source]
Parameters:
  • filename

  • full