lib/timetrap/cli.rb in timetrap-1.8.11 vs lib/timetrap/cli.rb in timetrap-1.8.12

- old
+ new

@@ -36,11 +36,13 @@ defined fomatter classes default_formatter: The format to use when display is invoked without a `--format` option default_command: The default command to run when calling t. auto_checkout: Automatically check out of running entries when - you check in + you check in or out + require_note: Prompt for a note if one isn't provided when + checking in * display - Display the current timesheet or a specific. Pass `all' as SHEET to display all unarchived sheets or `full' to display archived and unarchived sheets. usage: t display [--ids] [--start DATE] [--end DATE] [--format FMT] [SHEET | all | full] @@ -76,11 +78,11 @@ usage: t list * now - Show all running entries. usage: t now - * out - Stop the timer for the a timesheet. + * out - Stop the timer for a timesheet. usage: t out [--at TIME] [TIMESHEET] -a, --at <time:qs> Use this time instead of now * resume - Start the timer for the current time sheet with the same note as the last entry on the sheet. If there is no entry it takes the passed note. @@ -251,10 +253,16 @@ if Config['auto_checkout'] Timer.stop_all(args['-a']).each do |checked_out_of| warn "Checked out of sheet #{checked_out_of.sheet.inspect}." end end + + if Config['require_note'] && !Timer.running? && unused_args.empty? + $stderr.print("Please enter a note for this entry:\n> ") + self.unused_args = $stdin.gets + end + Timer.start unused_args, args['-a'] warn "Checked into sheet #{Timer.current_sheet.inspect}." end def resume @@ -268,14 +276,23 @@ self.in end def out - sheet = sheet_name_from_string(unused_args) - if Timer.stop sheet, args['-a'] - warn "Checked out of sheet #{sheet.inspect}." + if Config['auto_checkout'] + stopped = Timer.stop_all(args['-a']).each do |checked_out_of| + warn "Checked out of sheet #{checked_out_of.sheet.inspect}." + end + if stopped.empty? + warn "No running entries to stop." + end else - warn "No running entry on sheet #{sheet.inspect}." + sheet = sheet_name_from_string(unused_args) + if Timer.stop sheet, args['-a'] + warn "Checked out of sheet #{sheet.inspect}." + else + warn "No running entry on sheet #{sheet.inspect}." + end end end def kill if e = Entry[args['-i']]