Data Integrator (Python API)
Public Member Functions | List of all members
cls.ArgumentParserBase._CPrintChoicesAction Class Reference

Print option lists. More...

Inheritance diagram for cls.ArgumentParserBase._CPrintChoicesAction:
Inheritance graph
[legend]
Collaboration diagram for cls.ArgumentParserBase._CPrintChoicesAction:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, option_strings, choices, dest=SUPPRESS, default=SUPPRESS, help=None)
 
def __call__ (s, parser, namespace, values, option_string=None)
 

Detailed Description

Print option lists.

This class has been designed in order to implement options that print
elements of a @c list and immediately quit the parser without taking care
of any other arguments. This behavior is like the help or version option,
as it quits after printing something. A typical example is

@code
import argparse
parser = argparse.ArgumentParser(description='Print possible options.')
parser.register('action', 'choices', _CPrintChoicesAction)
parser.add_argument('--list-keywords', choices=('foo', 'bar'), action='choices')
parser.parse_args(['--list-keywords', '--will-be-ignored'])
@endcode

where only output of the options 'foo' and 'bar' is enforeced, even if the
program itself serves a different purpose.

This functionality can only be
implemented as a separate action, since as a simple option it would
undergo all command line option checking prior to printing and therefore
would raise errors since other mandatory options were not be supplied.
@param option_strings  Name(s) of the option, eg. '--list-keywords'.
@param choices  @c List of @c strings to print.

Constructor & Destructor Documentation

◆ __init__()

def cls.ArgumentParserBase._CPrintChoicesAction.__init__ (   self,
  option_strings,
  choices,
  dest = SUPPRESS,
  default = SUPPRESS,
  help = None 
)

Member Function Documentation

◆ __call__()

def cls.ArgumentParserBase._CPrintChoicesAction.__call__ (   s,
  parser,
  namespace,
  values,
  option_string = None 
)

The documentation for this class was generated from the following file: