/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 14:21:53 UTC
  • Revision ID: tim@ed.am-20160213142153-68g7pzq0au6bejep
fixed init command

Show diffs side-by-side

added added

removed removed

117
117
                        'rm': 'remove',
118
118
                        'st': 'status',
119
119
                        'co': 'init',
120
 
                        'ci': 'add',
121
120
                }.get( command, False )
122
121
                if alias: return alias
123
122
 
142
141
 
143
142
        def run( self ):
144
143
                # make an initial attempt to parse the command line, looking only for
145
 
                # --help and --version so that they have the chance to run without a
146
 
                # command being specified
 
144
                # --help, --version and --verbose, so that they have the chance to run
 
145
                # without a command being specified
147
146
                try:
148
147
                        opts, args = getopt.gnu_getopt(
149
 
                                sys.argv[ 1: ], "",
150
 
                                [ "help", "version" ] )
 
148
                                sys.argv[ 1: ], "v",
 
149
                                [ "verbose", "help", "version" ] )
151
150
 
152
151
                        for opt, optarg in opts:
153
152
                                # we only show help if there are no non-option arguments (e.g.,
154
153
                                # a command) specified.  If a command has been specified it will
155
154
                                # have to be parsed and --help will be handled by it, instead)
156
 
                                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:
157
158
                                        self.print_help()
158
159
                                elif opt == "--version":
159
160
                                        self.print_version()
208
209
                try:
209
210
                        instance.run()
210
211
                except Vcs.VcsError as e:
211
 
                        message = e.msg.rstrip() + '\n\nVCS OUTPUT:\n' + e.output.rstrip()
 
212
                        message = e.msg.rstrip()
 
213
                        if the.verbose >= 1:
 
214
                                message += '\n\nOUTPUT:\n' + e.output.rstrip()
212
215
                        self.die( message )
213
216
                except self.FatalError as e:
214
217
                        self.die( e.msg )