Commandline Tool

class pcsg.tool.Tool(name: Optional[str] = None, description: Optional[str] = None)

Base class for implementing own command line tools.

addAnimation(animation)

Adds an animation to this tool.

addOption(option)

Add a command line option to the tool.

animators

Animators of tool.

attributes()

Returns the default attributes to be applied on processing.

description

Description of tool.

name

Name of tool

options

Command line options of tool.

run(commandLineArgs: Optional[list] = None)

Runs the tool.

scene(attributes)

Generate a scene (csg tree).

Commandline Arguments

class pcsg.util.commandline.Option(name: str, short: str, description: str, default, group, filterFunc)

The base class of Flags and Parameters.

default

Default value for optional Options.

description

Description of the Option (required for displaying help).

filterFunc

Filter function to check parsed values. def filter (Option, Value) -> str: Function shall return an error string for bad arguments, None if accepted.

group

Group name (required for displaying help).

name

Name of the Option (required for displaying help).

short

Short identifier string (a single char).

value

Value after parsing the commandline.

class pcsg.util.commandline.Flag(name: str, short: str, description: str, group: str, filterFunc=None)

Flag for command line parser. A flag is simply a boolean flag which is parsed from a command line argument in form --name or -s(hort).

class pcsg.util.commandline.Parameter(name: str, short: str, description: str, group: str, default=None, valueName=None, filterFunc=None)

Parameter for command line parser. A parameter is a data value parsed from a command line argument in form --name value or -s(hort) value.

valueName

Name of value (required for displaying help).

class pcsg.util.commandline.ParameterChoose(name: str, short: str, description: str, group: str, items: dict, default=None, valueName=None, filterFunc=None)

Like Parameter, but the choosable options are fixed by a list.

items

A dictionary containing the chooseable items. The key is the option string for the command line. Value should contain a dict {‘description’: aString} for displaying the help.

valueName

Name of value (required for displaying help).

class pcsg.util.commandline.Argument(name: str, description: str, isOptional: bool = False, optionalParsing: bool = False, default=None, isArray: bool = False, filterFunc=None)

Argument for command line parser. Arguments get parsed in the order the are registered at the Parser.

default

Default value for optional Argument.

description

Description of the Argument (required for displaying help).

filterFunc

Filter function to check parsed values. def filter (Option, Value) -> str: Function shall return an error string for bad arguments, None if accepted.

isArray

The Argument is parsed as array and can be used multiple times.

isOptional

If True, the Argument is displayed as optional (required for displaying help).

name

Name of the Argument (required for displaying help).

optionalParsing

If True, the Argument is parsed as optional (required for parsing).

value

Value after parsing the commandline.

class pcsg.util.commandline.ArgumentChoose(name, description, items: dict, isOptional=False, optionalParsing=False, default=None, isArray=False, filterFunc=None)

Like Argument, but the choosable options are fixed by a list.

class pcsg.util.commandline.ExtraArguments(name, description)

ExtraArguments takes all extra command line arguments after -- was parsed. Arguments -- are not interpreted by the Parser.

Commandline Parameter Filters

Filter methods are used to check the type of a parsed parameter.

commandline.FilterNumber(value)

Filter: Assert number.

commandline.FilterNumberGreterZero(value)

Filter: Assert number greater than zero.

commandline.FilterInteger(value)

Filter: Assert integral number.

commandline.FilterIntegerGreterZero(value)

Filter: Assert integral number greater than zero.

Commandline Parser

class pcsg.util.commandline.Parser(title=None, description=None)

Parser for command line with integrated help system.

commandlineInvalid(message)

Print error and terminate application with error code 1.

dumpParsed(withDefaults=False, prefix=' ')

Dump parsed command line options.

parse(arguments=None)

Parse command line arguments.

register(entry)

Register flag, parameter or argument.

showHelp(withDescription=True)

Show command line help.