Anonymous avatar Anonymous committed 7cb710a

Took Trevor's UI suggestions

Comments (0)

Files changed (1)

timebook/commands.py

 the sqlite3 command.''')
     subprocess.call(('sqlite3', db.path))
 
-@command('display the current timesheet', aliases=('show',))
-def display(db, args):
-    format(db, ["--format=timebook"] + args)
-
 @command('start the timer for the current timesheet', name='in',
          aliases=('start',))
 def in_(db, args, extra=None):
             active = duration
     print '%s: %s' % (sheet, active)
 
-class NoSuchFormat(ValueError):
-    pass
-
-@command('export a sheet to csv format', aliases=('csv', 'export'))
-def format(db, args):
+@command('display timesheet, by default the current one',
+         aliases=('export', 'format', 'show'))
+def display(db, args):
     # arguments
-    parser = OptionParser(usage='''usage: %prog [format|display] [TIMESHEET]
+    parser = OptionParser(usage='''usage: %prog display [TIMESHEET]
 
 Display the data from a timesheet in the range of dates specified, either
-in the normal timebook fashion (using the display command or
---format=timebook) or as comma-separated value format spreadsheet, which
+in the normal timebook fashion (using --format=plain) or as
+comma-separated value format spreadsheet (using --format=csv), which
 ignores the final entry if active.
 
 If a specific timesheet is given, display the same information for that
 ending before 00:00 on this date. The date should be of the format \
 YYYY-MM-DD.')
     parser.add_option('-f', '--format', dest='format', type='string',
-                  help="Select whether to output timebook-style or csv")
+                  default='plain',
+                  help="Select whether to output in the normal timebook \
+style (--format=plain) or csv --format=csv")
     opts, args = parser.parse_args(args=args)
 
     # grab correct sheet
         end_date = datetime.strptime(opts.end, fmt)
         end = cmdutil.datetime_to_int(end_date)
         where += ' and end_time <= %s' % end
-    if opts.format == 'timebook':
+    if opts.format == 'plain':
         format_timebook(db, sheet, where)
     elif opts.format == 'csv':
         format_csv(db, sheet, where)
     else:
-        raise NoSuchFormat(opts.format)
+        print >>sys.stderr, 'Invalid format: %s' % opts.format
+        raise SystemExit()
 
 def format_csv(db, sheet, where):
     import csv
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 ProjectModifiedEvent.java.
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.