diff options
| author | Zack Hobson | 2013-11-21 09:18:03 -0800 |
|---|---|---|
| committer | Zack Hobson | 2013-11-21 09:18:03 -0800 |
| commit | 86ff02c8380fc50cfa7e0d4e6d0cfd7be56fb633 (patch) | |
| tree | 3ccb8c86c23ed5b4fa9824f06cbe63d23a106986 /lib | |
| parent | a5b1269024c2bbc1d4faffcd9753636cb548f712 (diff) | |
| download | hcl-86ff02c8380fc50cfa7e0d4e6d0cfd7be56fb633.tar.bz2 | |
tasks: list tasks by project code
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hcl/commands.rb | 11 | ||||
| -rw-r--r-- | lib/hcl/task.rb | 6 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index b31cca7..3d1b494 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -3,14 +3,15 @@ require 'highline' module HCl module Commands - def tasks + def tasks project_code=nil tasks = Task.all + DayEntry.all if tasks.empty? # cache tasks + tasks.select! {|t| t.project.code == project_code } if project_code if tasks.empty? - puts "No cached tasks. Run `hcl show' to populate the cache and try again." - else - tasks.each { |task| puts "#{task.project.id} #{task.id}\t#{task}" } + puts "No matching tasks." + exit 1 end - nil + tasks.map { |task| "#{task.project.id} #{task.id}\t#{task}" }.join("\n") end def set key = nil, *args diff --git a/lib/hcl/task.rb b/lib/hcl/task.rb index 508a0c0..3cb25b9 100644 --- a/lib/hcl/task.rb +++ b/lib/hcl/task.rb @@ -45,7 +45,11 @@ module HCl end def to_s - "#{project.client} - #{project.name} - #{name}" + if project.code.empty? + "#{project.client} - #{project.name} - #{name}" + else + "#{project.client} - [#{project.code}] #{project.name} - #{name}" + end end def add opts |
