lib/timetrap/cli.rb in timetrap-1.4.1 vs lib/timetrap/cli.rb in timetrap-1.5.0
- old
+ new
@@ -26,14 +26,17 @@
-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. Currently supports ical, csv, and
text (default).
* edit - alter an entry's note, start, or end time. Defaults to the active entry
- usage: t edit [--id ID] [--start TIME] [--end TIME] [NOTES]
+ usage: t edit [--id ID] [--start TIME] [--end TIME] [--append] [NOTES]
-i, --id <id:i> Alter entry with id <id> instead of the running entry
-s, --start <time:qs> Change the start time to <time>
-e, --end <time:qs> Change the end time to <time>
+ -z, --append Append to the current note instead of replacing it
+ the delimiter between appended notes is
+ configurable (see configure)
* format - deprecated: alias for display
* in - start the timer for the current timesheet
usage: t in [--at TIME] [NOTES]
-a, --at <time:qs> Use this time instead of now
* kill - delete a timesheet
@@ -65,10 +68,13 @@
args.parse arguments
end
def invoke
args['-h'] ? say(USAGE) : invoke_command_if_valid
+ rescue => e
+ say e.message
+ exit 1
end
def commands
Timetrap::CLI::USAGE.scan(/\* \w+/).map{|s| s.gsub(/\* /, '')}
end
@@ -114,10 +120,16 @@
def edit
entry = args['-i'] ? Entry[args['-i']] : Timetrap.active_entry
say "can't find entry" && return unless entry
entry.update :start => args['-s'] if args['-s'] =~ /.+/
entry.update :end => args['-e'] if args['-e'] =~ /.+/
- entry.update :note => unused_args if unused_args =~ /.+/
+ if unused_args =~ /.+/
+ note = unused_args
+ if args['-z']
+ note = [entry.note, note].join(Config['append_notes_delimiter'])
+ end
+ entry.update :note => note
+ end
end
def backend
exec "sqlite3 #{DB_NAME}"
end