summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.markdown10
-rw-r--r--lib/hcl/commands.rb11
-rw-r--r--lib/hcl/task.rb6
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