diff options
| author | Zack Hobson | 2009-07-19 11:34:52 -0700 |
|---|---|---|
| committer | Zack Hobson | 2009-07-19 11:34:52 -0700 |
| commit | 490035c83e9518ac8dfdf86c9ef931bcbdd8d47a (patch) | |
| tree | e5b54dc3fd3981d0aa303adb80e15cc4664a1c9a /lib/hcl.rb | |
| parent | 8db6dee90d5258b7861668ccb8aac82733f6e2dd (diff) | |
| download | hcl-490035c83e9518ac8dfdf86c9ef931bcbdd8d47a.tar.bz2 | |
implement show by date
Diffstat (limited to 'lib/hcl.rb')
| -rw-r--r-- | lib/hcl.rb | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -2,6 +2,7 @@ require 'yaml' require 'rubygems' require 'curb' +require 'chronic' require 'hcl/day_entry' @@ -17,7 +18,7 @@ class HCl hcl = new(@@conf_file).process_args *args if command if hcl.respond_to? command - hcl.send command + hcl.send command, *args else raise UnknownCommand, "unrecognized command `#{command}'" end @@ -36,11 +37,17 @@ class HCl puts <<-EOM Usage: - hcl [opts] add <project> <task> <duration> [msg] - hcl [opts] rm [entry_id] - hcl [opts] start <project> <task> [msg] - hcl [opts] stop [msg] - hcl [opts] show [date] + hcl show [date] + hcl add <project> <task> <duration> [msg] + hcl rm [entry_id] + hcl start <project> <task> [msg] + hcl stop [msg] + + Examples: + + hcl show 2009-07-15 + hcl show yesterday + hcl show last tuesday EOM end def help; self.class.help; end @@ -50,11 +57,12 @@ class HCl self end - def show + def show *args + date = args.empty? ? nil : Chronic.parse(args.join(' ')) total_hours = 0.0 - DayEntry.all.each do |day| + DayEntry.all(date).each do |day| # TODO more information and formatting options - puts "\t#{day.hours}\t#{day.project} (#{day.notes})"[0..78] + puts "\t#{day.hours}\t#{day.project} #{day.notes}"[0..78] total_hours = total_hours + day.hours.to_f end puts "\t" + '-' * 13 |
