Next / Previous / Contents / TCC Help System / NM Tech homepage

4.11. class Args: Command line argument object

This class encapsulates the processing of the command line arguments.

class Args:
    """Represents the command line arguments.

          [ if sys.argv contains valid command line arguments ->
              return a new Args object representing those arguments
            else ->
              sys.stderr  +:=  (usage message) + (error message)
              stop execution ]
          [ the input file name argument from sys.argv ]
          [ if sys.argv specifies a prefix argument ->
              that argument as a string
            else -> "" ]
          [ if sys.argv specifies an output file name ->
              that file name as a string
            else -> None ]

Class variables include short and long option names and the name of the one required positional argument.

    PREFIX_SHORT = '-p'; PREFIX_LONG = '--prefix'
    OUT_SHORT = '-o'; OUT_LONG = '--out'
    IN_FILE_ARG = 'inFileName'