zenhob-hcl 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -4
- data/VERSION.yml +1 -1
- data/hcl.gemspec +2 -2
- data/lib/hcl.rb +32 -20
- metadata +2 -2
data/README.markdown
CHANGED
@@ -14,6 +14,7 @@ HCl is a command-line tool for interacting with Harvest time sheets using the
|
|
14
14
|
|
15
15
|
* Ruby (tested with 1.8.7)
|
16
16
|
* Ruby OpenSSL support (in debian/ubuntu: apt-get install libopenssl-ruby)
|
17
|
+
* Ruby extension building support (in debian/ubuntu: apt-get install ruby-dev)
|
17
18
|
* RubyGems
|
18
19
|
* Trollop option-parsing library (gem install trollop)
|
19
20
|
* Chronic date-parsing library (gem install chronic)
|
@@ -22,8 +23,6 @@ HCl is a command-line tool for interacting with Harvest time sheets using the
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
NOTE that *add* and *rm* are not yet implemented.
|
26
|
-
|
27
26
|
hcl show [date]
|
28
27
|
hcl tasks
|
29
28
|
hcl set <key> <value ...>
|
@@ -31,8 +30,6 @@ NOTE that *add* and *rm* are not yet implemented.
|
|
31
30
|
hcl start (<task_alias> | <project_id> <task_id>) [msg ...]
|
32
31
|
hcl note <msg ...>
|
33
32
|
hcl stop
|
34
|
-
hcl add (<task_alias> | <project_id> <task_id>) <duration> [msg ...]
|
35
|
-
hcl rm [entry_id]
|
36
33
|
|
37
34
|
### Starting a Timer
|
38
35
|
|
data/VERSION.yml
CHANGED
data/hcl.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{hcl}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Zack Hobson"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-28}
|
10
10
|
s.default_executable = %q{hcl}
|
11
11
|
s.description = %q{HCl is a command-line client for manipulating Harvest time sheets.}
|
12
12
|
s.email = %q{zack@opensourcery.com}
|
data/lib/hcl.rb
CHANGED
@@ -38,7 +38,14 @@ class HCl
|
|
38
38
|
def run
|
39
39
|
if @command
|
40
40
|
if respond_to? @command
|
41
|
-
send @command, *@args
|
41
|
+
result = send @command, *@args
|
42
|
+
if not result.nil?
|
43
|
+
if result.respond_to? :to_a
|
44
|
+
puts result.to_a.join(', ')
|
45
|
+
elsif result.respond_to? :to_s
|
46
|
+
puts result
|
47
|
+
end
|
48
|
+
end
|
42
49
|
else
|
43
50
|
raise UnknownCommand, "unrecognized command `#{@command}'"
|
44
51
|
end
|
@@ -68,12 +75,11 @@ HCl is a command-line client for manipulating Harvest time sheets.
|
|
68
75
|
Commands:
|
69
76
|
hcl show [date]
|
70
77
|
hcl tasks
|
78
|
+
hcl aliases
|
71
79
|
hcl set <key> <value ...>
|
72
80
|
hcl start <task> [msg]
|
73
81
|
hcl stop [msg]
|
74
82
|
hcl note <msg>
|
75
|
-
hcl add <task> <duration> [msg]
|
76
|
-
hcl rm [entry_id]
|
77
83
|
|
78
84
|
Examples:
|
79
85
|
$ hcl tasks
|
@@ -92,10 +98,13 @@ EOM
|
|
92
98
|
end
|
93
99
|
|
94
100
|
def tasks
|
95
|
-
Task.all
|
96
|
-
|
97
|
-
puts "
|
101
|
+
tasks = Task.all
|
102
|
+
if tasks.empty?
|
103
|
+
puts "No cached tasks. Run `hcl show' to populate the cache and try again."
|
104
|
+
else
|
105
|
+
tasks.each { |task| puts "#{task.project.id} #{task.id}\t#{task}" }
|
98
106
|
end
|
107
|
+
nil
|
99
108
|
end
|
100
109
|
|
101
110
|
def read_config
|
@@ -136,6 +145,7 @@ EOM
|
|
136
145
|
File.open(SETTINGS_FILE, 'w') do |f|
|
137
146
|
f.write @settings.to_yaml
|
138
147
|
end
|
148
|
+
nil
|
139
149
|
end
|
140
150
|
|
141
151
|
def set key = nil, *args
|
@@ -149,6 +159,7 @@ EOM
|
|
149
159
|
@settings[key] = value
|
150
160
|
write_settings
|
151
161
|
end
|
162
|
+
nil
|
152
163
|
end
|
153
164
|
|
154
165
|
def unset key
|
@@ -156,22 +167,31 @@ EOM
|
|
156
167
|
write_settings
|
157
168
|
end
|
158
169
|
|
170
|
+
def aliases
|
171
|
+
@settings.keys.select { |s| s =~ /^task\./ }.map { |s| s.slice(5..-1) }
|
172
|
+
end
|
173
|
+
|
159
174
|
def start *args
|
160
175
|
ident = args.shift
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
176
|
+
task_ids = if @settings.key? "task.#{ident}"
|
177
|
+
@settings["task.#{ident}"].split(/\s+/)
|
178
|
+
else
|
179
|
+
[ident, args.shift]
|
180
|
+
end
|
181
|
+
task = Task.find *task_ids
|
182
|
+
if task.nil?
|
183
|
+
puts "Unknown project/task alias, try one of the following: #{aliases.join(', ')}."
|
184
|
+
exit 1
|
165
185
|
end
|
166
186
|
task.start(*args)
|
167
|
-
puts "Started timer for #{task}"
|
187
|
+
puts "Started timer for #{task}."
|
168
188
|
end
|
169
189
|
|
170
190
|
def stop
|
171
191
|
entry = DayEntry.with_timer
|
172
192
|
if entry
|
173
193
|
entry.toggle
|
174
|
-
puts "Stopped #{entry}"
|
194
|
+
puts "Stopped #{entry}."
|
175
195
|
else
|
176
196
|
puts "No running timers found."
|
177
197
|
end
|
@@ -207,13 +227,5 @@ EOM
|
|
207
227
|
sprintf "%d:%02d", (minutes / 60).to_i, (minutes % 60).to_i
|
208
228
|
end
|
209
229
|
|
210
|
-
def not_implemented *args
|
211
|
-
puts "not yet implemented"
|
212
|
-
end
|
213
|
-
|
214
|
-
# TODO implement the following commands
|
215
|
-
alias add not_implemented
|
216
|
-
alias rm not_implemented
|
217
|
-
|
218
230
|
end
|
219
231
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenhob-hcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hobson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-28 00:00:00 -07:00
|
13
13
|
default_executable: hcl
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|