diff options
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 |
