argclz.core.AbstractParser#

class argclz.core.AbstractParser[source]#

Bases: object

Commandline parser.

__init__()#

Methods Summary

__init__()

main([args, parse_only, system_exit])

parsing the commandline input args and call run().

new_parser(**kwargs)

create an ArgumentParser.

run()

called after main().

Attributes Summary

DESCRIPTION

parser description.

EPILOG

parser epilog.

USAGE

parser usage.

Details

USAGE: str | list[str] | None = None#

parser usage.

DESCRIPTION: str | None = None#

parser description. Could be override as a method if its content is dynamic-generated.

EPILOG: str | None = None#

parser epilog. Could be override as a method if its content is dynamic-generated.

classmethod new_parser(**kwargs)[source]#

create an ArgumentParser.

Parameters:

kwargs – keyword parameters to argparse.ArgumentParser

Returns:

an ArgumentParser.

Return type:

ArgumentParser

main(args=None, *, parse_only=False, system_exit=<class 'SystemExit'>)[source]#

parsing the commandline input args and call run().

Parameters:
  • args (list[str] | None) – command-line arguments. If omitted, use sys.args.

  • parse_only – parse command-line arguments only, do not raise error and invoke run()

  • system_exit (Type[BaseException] | bool) – error raised when commandline parsed fail.

Returns:

parser itself. If it has sub command, return sub parser when used.

Return type:

AbstractParser

run()[source]#

called after main(). Used for runs the main execution logic of the object