Next / Previous / Contents / Shipman's homepage

14.2. Args.__buildParser(): Generate a command line parser

nomcompile3
# - - -   A r g s . _ _ b u i l d P a r s e r

    def __buildParser ( self ):
        '''Construct a command-line argument parser.

          [ return an optparse.OptionParser instance that
            processes this program's command line arguments ]
        '''

Refer to the documentation for the optparse module.

nomcompile3
        #-- 1 --
        # [ parser  :=  a new optparse.OptionParser instance ]
        parser = OptionParser ( version="%s %s" %
            (PROGRAM_NAME, EXTERNAL_VERSION) )

        #-- 2 --
        # [ parser  :=  parser with this program's command line
        #       options added ]
        parser.add_option ( "-r", "--ranks",
            dest="ranksFileName",
            help="Name of the ranks file." )

        #-- 3 --
        return parser