/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/program.py

  • Committer: Tim Marston
  • Date: 2016-02-13 13:20:44 UTC
  • Revision ID: tim@ed.am-20160213132044-t5zaxhdlhjyn4t1v
moved handling of --verbose to main program; manuall parse config file (because
ConfigFileParse does not support allow_no_value in python 2.6)

Show diffs side-by-side

added added

removed removed

141
141
 
142
142
        def run( self ):
143
143
                # make an initial attempt to parse the command line, looking only for
144
 
                # --help and --version, so that they have the chance to run without a
145
 
                # command being specified
 
144
                # --help, --version and --verbose, so that they have the chance to run
 
145
                # without a command being specified
146
146
                try:
147
147
                        opts, args = getopt.gnu_getopt(
148
 
                                sys.argv[ 1: ], "",
149
 
                                [ "help", "version" ] )
 
148
                                sys.argv[ 1: ], "v",
 
149
                                [ "verbose", "help", "version" ] )
150
150
 
151
151
                        for opt, optarg in opts:
152
152
                                # we only show help if there are no non-option arguments (e.g.,
153
153
                                # a command) specified.  If a command has been specified it will
154
154
                                # have to be parsed and --help will be handled by it, instead)
155
 
                                if opt == "--help" and len( args ) == 0:
 
155
                                if opt in [ '--verbose', '-v' ]:
 
156
                                        the.verbose += 1
 
157
                                elif opt == "--help" and len( args ) == 0:
156
158
                                        self.print_help()
157
159
                                elif opt == "--version":
158
160
                                        self.print_version()