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.

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

      Exports:
        Args():
          [ 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 ]
        .inFileName:
          [ the input file name argument from sys.argv ]
        .prefix:
          [ if sys.argv specifies a prefix argument ->
              that argument as a string
            else -> "" ]
        .outFileName:
          [ 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.

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