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 | |
| parent | a5b1269024c2bbc1d4faffcd9753636cb548f712 (diff) | |
| download | hcl-86ff02c8380fc50cfa7e0d4e6d0cfd7be56fb633.tar.bz2 | |
tasks: list tasks by project code
| -rw-r--r-- | README.markdown | 10 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 11 | ||||
| -rw-r--r-- | lib/hcl/task.rb | 6 | 
3 files changed, 15 insertions, 12 deletions
| diff --git a/README.markdown b/README.markdown index a8d2fc0..e114006 100644 --- a/README.markdown +++ b/README.markdown @@ -15,11 +15,6 @@ or you can install from source:      $ rake install -If you're using HCl for the first time, the show command sets up your -Harvest credentials: - -    $ hcl show -  ## Usage      hcl [start] @<task_alias> [+<time>] [<message>] @@ -28,7 +23,7 @@ Harvest credentials:      hcl resume [@<task_alias>]      hcl log @<task_alias> [+<time>] [<message>]      hcl show [<date>] -    hcl tasks +    hcl tasks [<project_code>]      hcl alias <task_alias> <project_id> <task_id>      hcl aliases      hcl (cancel | nvm | oops) @@ -41,6 +36,9 @@ available tasks.      $ hcl tasks +You can also pass a project code (this is the short optional code associated +with each project) to list only the tasks for that project. +  ### Starting a Timer  Since it's not practical to enter two long numbers every time you want to 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 | 
