lib/timetrap/cli.rb in timetrap-1.7.3 vs lib/timetrap/cli.rb in timetrap-1.7.4
- old
+ new
@@ -38,11 +38,11 @@
usage: t display [--ids] [--start DATE] [--end DATE] [--format FMT] [SHEET | all]
-v, --ids Print database ids (for use with edit)
-s, --start <date:qs> Include entries that start on this date or later
-e, --end <date:qs> Include entries that start on this date or earlier
-f, --format <format> The output format. Valid built-in formats are
- ical, csv, json, ids, and text (default).
+ ical, csv, json, ids, factor, and text (default).
Documentation on defining custom formats can be
found in the README included in this
distribution.
* edit - Alter an entry's note, start, or end time. Defaults to the active entry.
@@ -77,11 +77,12 @@
the last entry on the sheet. If there is no entry it takes the passed note.
usage: t resume [--at TIME] [NOTES]
-a, --at <time:qs> Use this time instead of now
* sheet - Switch to a timesheet creating it if necessary. When no sheet is
- specified list all sheets.
+ specified list all sheets. The special sheetname '-' will switch to the
+ last active sheet.
usage: t sheet [TIMESHEET]
* week - Shortcut for display with start date set to monday of this week.
usage: t week [--ids] [--end DATE] [--format FMT] [SHEET | all]
@@ -268,16 +269,25 @@
end
end
def sheet
sheet = unused_args
- unless sheet =~ /.+/
+ case sheet
+ when nil, ''
list
- else
- Timer.current_sheet = sheet
- warn "Switching to sheet #{sheet.inspect}"
+ return
+ when '-'
+ if Timer.last_sheet
+ sheet = Timer.last_sheet
+ else
+ warn 'LAST_SHEET is not set'
+ return
+ end
end
+
+ Timer.current_sheet = sheet
+ warn "Switching to sheet #{sheet.inspect}"
end
def list
sheets = ([Timer.current_sheet] | Entry.sheets).map do |sheet|
sheet_atts = {:total => 0, :running => 0, :today => 0}
@@ -312,10 +322,10 @@
puts "*#{Timer.current_sheet}: not running"
end
Timer.running_entries.each do |entry|
current = entry[:sheet] == Timer.current_sheet
out = current ? '*' : ' '
- out << "#{entry[:sheet]}: #{format_duration(entry.start, entry.end_or_now)}".gsub(/ /, ' ')
+ out << "#{entry[:sheet]}: #{format_duration(entry.duration)}".gsub(/ /, ' ')
out << " (#{entry.note})" if entry.note =~ /.+/
puts out
end
end