diff options
| author | Zack Hobson | 2009-07-30 11:37:18 -0700 |
|---|---|---|
| committer | Zack Hobson | 2009-07-30 11:37:18 -0700 |
| commit | d2de12ef6cec9d8de1e06fc6096a1dff75f96ab1 (patch) | |
| tree | 4936c62dbf2de67d45780db6566d1342fe79fa83 /lib/hcl.rb | |
| parent | 31a3a51bf078cb771dbdf44985a1f4e9121ff5c4 (diff) | |
| download | hcl-d2de12ef6cec9d8de1e06fc6096a1dff75f96ab1.tar.bz2 | |
Allow an initial time to be specified when starting a timer, closes #9.
Diffstat (limited to 'lib/hcl.rb')
| -rw-r--r-- | lib/hcl.rb | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -7,6 +7,7 @@ require 'chronic' require 'trollop' require 'highline/import' +require 'hcl/utility' require 'hcl/timesheet_resource' require 'hcl/project' require 'hcl/task' @@ -25,6 +26,8 @@ class Net::HTTP end class HCl + include Utility + VERSION_FILE = File.dirname(__FILE__) + '/../VERSION.yml' SETTINGS_FILE = "#{ENV['HOME']}/.hcl_settings" CONFIG_FILE = "#{ENV['HOME']}/.hcl_config" @@ -172,6 +175,11 @@ EOM end def start *args + starting_time = args.detect {|x| x =~ /^\+\d*(\.|:)\d+$/ } + if starting_time + args.delete(starting_time) + starting_time = time2float starting_time + end ident = args.shift task_ids = if @settings.key? "task.#{ident}" @settings["task.#{ident}"].split(/\s+/) @@ -183,8 +191,8 @@ EOM puts "Unknown project/task alias, try one of the following: #{aliases.join(', ')}." exit 1 end - task.start(*args) - puts "Started timer for #{task}." + timer = task.start(:starting_time => starting_time, :note => args.join(' ')) + puts "Started timer for #{timer}." end def stop @@ -217,7 +225,7 @@ EOM total_hours = total_hours + day.hours.to_f end puts "\t" + '-' * 13 - puts "\t#{HCl::DayEntry.as_hours total_hours}\ttotal" + puts "\t#{as_hours total_hours}\ttotal" end end |
