Package csb :: Package apps :: Class ArgHandler |
[frames] | no frames]

# Class ArgHandler

source code

    object --+
             |
            ArgHandler

Command line argument handler.

Note: a help argument (-h) is provided automatically.

Nested Classes
| Type

Instance Methods
__init__(self, program, description=`'````'`) x.__init__(...) initializes x; see help(type(x)) for signature | source code
add_array_argument(self, name, type, help, choices=None) Same as self.add_positional_argument(), but allow unlimited number of values to be specified on the command line. | source code
add_array_option(self, name, shortname, type, help, default=None, choices=None, required=False) Define an array option (a dashed argument that may receive one or multiple values on the command line, separated with spaces). | source code
add_boolean_option(self, name, shortname, help, default=False) Define an optional switch (a dashed argument with no value). | source code
add_positional_argument(self, name, type, help, choices=None) Define a mandatory positional argument (an argument without a dash). | source code
add_scalar_option(self, name, shortname, type, help, default=None, choices=None, required=False) Define a scalar option (a dashed argument that accepts a single value). | source code
argparse.Namespace |
parse(self, args) Parse the command line arguments. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Variables
| LONG_PREFIX = ``'``--``'``
| SHORT_PREFIX = ``'``-``'``

Properties
| help
| parser
| usage
Inherited from `object`: `__class__`

Method Details

### __init__(self, program, description=`'````'`) (Constructor) | source code
x.__init__(...) initializes x; see help(type(x)) for signature Parameters: `program` (str) - (file)name of the program, usually sys.argv[0] `description` (str) - long description of the application, shown in help pages. The usage line and the parameter lists are generated automatically, so no need to put them here. Overrides: object.__init__ (inherited documentation)

### add_array_argument(self, name, type, help, choices=None) | source code
Same as self.add_positional_argument(), but allow unlimited number of values to be specified on the command line. Parameters: `name` (str) - name of the argument (used in help only) `type` (type (type factory callable)) - argument data type `help` (str) - help text `choices` (tuple) - list of allowed argument values

### add_array_option(self, name, shortname, type, help, default=None, choices=None, required=False) | source code
Define an array option (a dashed argument that may receive one or multiple values on the command line, separated with spaces). Parameters: `name` (str, None) - long name of the option (or None) `shortname` (str, None) - short (single character) name of the option (or None) `type` (type (type factory callable)) - argument data type `help` (str) - help text `choices` (tuple) - list of allowed argument values `required` (bool) - make this option a named mandatory argument

### add_boolean_option(self, name, shortname, help, default=False) | source code
Define an optional switch (a dashed argument with no value). Parameters: `name` (str, None) - long name of the option (or None) `shortname` (str, None) - short (single character) name of the option (or None) `help` (str) - help text `default` (bool) - default value, assigned when the option is omitted. If the option is specified on the command line, the inverse value is assigned

### add_positional_argument(self, name, type, help, choices=None) | source code
Define a mandatory positional argument (an argument without a dash). Parameters: `name` (str) - name of the argument (used in help only) `type` (type (type factory callable)) - argument data type `help` (str) - help text `choices` (tuple) - list of allowed argument values

### add_scalar_option(self, name, shortname, type, help, default=None, choices=None, required=False) | source code
Define a scalar option (a dashed argument that accepts a single value). Parameters: `name` (str, None) - long name of the option (or None) `shortname` (str, None) - short (single character) name of the option (or None) `type` (type (type factory callable)) - argument data type `help` (str) - help text `default` - default value, assigned when the option is omitted `choices` (tuple) - list of allowed argument values `required` (bool) - make this option a named mandatory argument

### parse(self, args) | source code
Parse the command line arguments. Parameters: `args` (tuple of str) - the list of user-provided command line arguments -- normally sys.argv[1:] Returns: argparse.Namespace an object initialized with the parsed arguments

Property Details

### help Get Method: unreachable.help(self)

### parser Get Method: unreachable.parser(self)

### usage Get Method: unreachable.usage(self)