summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZack Hobson2009-07-21 21:05:36 -0700
committerZack Hobson2009-07-21 21:05:36 -0700
commit2f30e806d65971804351c02cbb9e2681b8873b04 (patch)
tree86ac79a27d3ee569e9831df3ed96d0fd9e54cfd9
parentfd5b5154f2d2c4d5988cca3c6650b7265750adfe (diff)
downloadhcl-2f30e806d65971804351c02cbb9e2681b8873b04.tar.bz2
Added note command.
-rw-r--r--README.markdown7
-rw-r--r--lib/hcl.rb18
-rw-r--r--lib/hcl/day_entry.rb12
3 files changed, 34 insertions, 3 deletions
diff --git a/README.markdown b/README.markdown
index 42bfb95..a8f1c74 100644
--- a/README.markdown
+++ b/README.markdown
@@ -57,6 +57,13 @@ identify a task, HCl supports task aliases:
$ hcl set task.xdev 1234 5678
$ hcl start xdev adding a new feature
+### Adding Notes to a Running Task
+
+While a task is running you can append strings to the note for that task:
+
+ $ hcl note Found a good time
+ $ hcl note or not, whatever...
+
### Stopping a Timer
The following command will stop a running timer (currently only one timer at
diff --git a/lib/hcl.rb b/lib/hcl.rb
index 9d80a8d..d0d6a9a 100644
--- a/lib/hcl.rb
+++ b/lib/hcl.rb
@@ -47,16 +47,18 @@ class HCl
def process_args *args
Trollop::options(args) do
version "HCl #{VERSION}"
+ stop_on %w[ show tasks set unset note add rm start stop ]
banner <<-EOM
HCl is a command-line client for manipulating Harvest time sheets.
Commands:
hcl show [date]
hcl tasks
- hcl add <task> <duration> [msg]
- hcl rm [entry_id]
hcl start <task> [msg]
hcl stop [msg]
+ hcl note <msg>
+ hcl add <task> <duration> [msg]
+ hcl rm [entry_id]
Examples:
$ hcl tasks
@@ -66,7 +68,6 @@ Examples:
Options:
EOM
- stop_on %w[ show tasks set unset add rm start stop ]
end
@command = args.shift
@args = args
@@ -134,6 +135,17 @@ EOM
end
end
+ def note *args
+ message = args.join ' '
+ entry = DayEntry.with_timer
+ if entry
+ entry.append_note message
+ puts "Added note '#{message}' to #{entry}."
+ else
+ puts "No running timers found."
+ end
+ end
+
def show *args
date = args.empty? ? nil : Chronic.parse(args.join(' '))
total_hours = 0.0
diff --git a/lib/hcl/day_entry.rb b/lib/hcl/day_entry.rb
index 42f52f4..a79ea2c 100644
--- a/lib/hcl/day_entry.rb
+++ b/lib/hcl/day_entry.rb
@@ -20,6 +20,18 @@ class HCl
end
end
+ # Append a string to the notes for this task.
+ def append_note new_notes
+ # If I don't include hours it gets reset.
+ # This doens't appear to be the case for task and project.
+ DayEntry.post("daily/update/#{id}", <<-EOD)
+ <request>
+ <notes>#{notes << " #{new_notes}"}</notes>
+ <hours>#{hours}</hours>
+ </request>
+ EOD
+ end
+
def self.with_timer
all.detect {|t| t.running? }
end