Anonymous avatar Anonymous committed 52f3565 Merge


Comments (0)

Files changed (1)


             'timebook': os.path.join(confdir, 'sheets.db'),
             'encoding': locale.getpreferredencoding()}
-def parse_options():
+def make_parser():
     cmd_descs = ['%s - %s' % (k, commands[k].description) for k
                  in sorted(commands)]
     parser = OptionParser(usage='''usage: %%prog [OPTIONS] COMMAND \
                       default=DEFAULTS['encoding'], help='Specify an \
 alternate encoding to decode command line options and arguments (default: \
 "%s")' % DEFAULTS['encoding'])
+    return parser
+def parse_options(parser):
     options, args = parser.parse_args()
     encoding = options.__dict__.pop('encoding')
         args = ['now'] + args
     return options, args
 def run_from_cmdline():
-    options, args = parse_options()
+    parser = make_parser()
+    options, args = parse_options(parser)
     config = parse_config(options.config)
     db = Database(options.timebook, config)
     cmd, args = args[0], args[1:]
         run_command(db, cmd, args)
     except NoMatch, e:
-        raise SystemExit, 'error: %s' % e.args[0]
+        parser.error('%s' % e.args[0])
     except AmbiguousLookup, e:
-        raise SystemExit, 'error: %s\n    %s' % (e.args[0],
-                                                 ' '.join(e.args[1]))
+        parser.error('%s\n    %s' % (e.args[0], ' '.join(e.args[1])))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.