hcl 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.markdown +9 -11
- data/VERSION +1 -1
- data/hcl.gemspec +2 -2
- data/lib/hcl/app.rb +2 -10
- data/lib/hcl/commands.rb +22 -39
- data/lib/hcl/day_entry.rb +5 -0
- data/lib/hcl/utility.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 852da2430771d5354f8fd2fca9bc55558e2248b7
|
4
|
+
data.tar.gz: 0f21a80c83c9e105829f872c47860e34975120e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a411682c2f8c9d049bfe3e13f436c9efd5c2cc3be9892d4ea9a3ed1b58008a60491d4f05530a9878af6a10ce6e9f7cd31b795caffce9727cbca0fddbb062e12
|
7
|
+
data.tar.gz: 7c1e0be48bbe9043a86265cc35d05feb3fb4bcc64b13c56fd4bbdcff9bce1e04c9b564702cfaabcca132ea8e9cad49993edd0a44be5d6b05bd0b720d881ea59a
|
data/README.markdown
CHANGED
@@ -30,15 +30,14 @@ or you can install from source using jeweler:
|
|
30
30
|
|
31
31
|
## Usage
|
32
32
|
|
33
|
+
hcl (@<task_alias> | <project_id> <task_id>) [+time] [message]
|
34
|
+
hcl note <message>
|
35
|
+
hcl stop [message]
|
36
|
+
hcl resume [@<task_alias>]
|
33
37
|
hcl show [date]
|
34
38
|
hcl tasks
|
35
|
-
hcl
|
36
|
-
hcl unset <key>
|
37
|
-
hcl start (<task_alias> | <project_id> <task_id>) [+time] [msg ...]
|
38
|
-
hcl note <msg ...>
|
39
|
+
hcl alias <task_alias> <project_id> <task_id>
|
39
40
|
hcl aliases
|
40
|
-
hcl stop [msg]
|
41
|
-
hcl resume
|
42
41
|
|
43
42
|
### Available Projects and Tasks
|
44
43
|
|
@@ -67,11 +66,8 @@ commands are equivalent:
|
|
67
66
|
|
68
67
|
### Adding Notes to a Running Task
|
69
68
|
|
70
|
-
While a task is running you can append lines to the task notes
|
71
|
-
Providing the note command is optional, just the bare message will work.
|
72
|
-
These two commands are equivalent:
|
69
|
+
While a task is running you can append lines to the task notes:
|
73
70
|
|
74
|
-
$ hcl Found a good time!
|
75
71
|
$ hcl note Found a good time!
|
76
72
|
|
77
73
|
### Stopping a Timer
|
@@ -84,9 +80,11 @@ well:
|
|
84
80
|
|
85
81
|
### Resuming a Timer
|
86
82
|
|
87
|
-
You can
|
83
|
+
You can resume a stopped timer. Specify a task to resume the last timer
|
84
|
+
for that task:
|
88
85
|
|
89
86
|
$ hcl resume
|
87
|
+
$ hcl resume @xdev
|
90
88
|
|
91
89
|
### Date Formats
|
92
90
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/hcl.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "hcl"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Zack Hobson"]
|
12
|
-
s.date = "2013-11-
|
12
|
+
s.date = "2013-11-19"
|
13
13
|
s.description = "HCl is a command-line client for manipulating Harvest time sheets."
|
14
14
|
s.email = "zack@zackhobson.com"
|
15
15
|
s.executables = ["hcl"]
|
data/lib/hcl/app.rb
CHANGED
@@ -31,7 +31,7 @@ class Net::HTTP
|
|
31
31
|
end
|
32
32
|
|
33
33
|
module HCl
|
34
|
-
VERSION = "0.
|
34
|
+
VERSION = "0.4.2"
|
35
35
|
|
36
36
|
class App
|
37
37
|
include HCl::Utility
|
@@ -61,14 +61,6 @@ module HCl
|
|
61
61
|
Commands.method_defined? command
|
62
62
|
end
|
63
63
|
|
64
|
-
def start_or_note *args
|
65
|
-
if DayEntry.with_timer
|
66
|
-
note *args
|
67
|
-
else
|
68
|
-
start *args
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
64
|
# Start the application.
|
73
65
|
def run
|
74
66
|
begin
|
@@ -83,7 +75,7 @@ module HCl
|
|
83
75
|
end
|
84
76
|
end
|
85
77
|
else
|
86
|
-
|
78
|
+
start @command, *@args
|
87
79
|
end
|
88
80
|
else
|
89
81
|
show
|
data/lib/hcl/commands.rb
CHANGED
@@ -41,6 +41,7 @@ module HCl
|
|
41
41
|
puts "Added alias @#{task_name} for #{task}."
|
42
42
|
else
|
43
43
|
puts "Unrecognized project and task ID: #{value.inspect}"
|
44
|
+
exit 1
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -49,48 +50,27 @@ module HCl
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def start *args
|
52
|
-
starting_time = args
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
ident = args.detect {|a| a[0] == '@' }
|
58
|
-
if ident
|
59
|
-
args.delete(ident)
|
60
|
-
ident = ident.slice(1..-1)
|
61
|
-
else
|
62
|
-
ident = args.shift
|
63
|
-
end
|
64
|
-
if ident
|
65
|
-
task_ids = if @settings.key? "task.#{ident}"
|
66
|
-
@settings["task.#{ident}"].split(/\s+/)
|
67
|
-
else
|
68
|
-
[ident, args.shift]
|
69
|
-
end
|
70
|
-
task = Task.find *task_ids
|
71
|
-
if task.nil?
|
72
|
-
puts "Unknown task alias, try one of the following: ", aliases.join(', ')
|
73
|
-
exit 1
|
74
|
-
end
|
75
|
-
timer = task.start(
|
76
|
-
:starting_time => starting_time,
|
77
|
-
:note => args.join(' ')
|
78
|
-
)
|
79
|
-
puts "Started timer for #{timer} (at #{current_time})"
|
80
|
-
else
|
81
|
-
puts "You must provide a task alias to start a timer:", aliases.join(', ')
|
53
|
+
starting_time = get_starting_time args
|
54
|
+
task = get_task args
|
55
|
+
if task.nil?
|
56
|
+
puts "Unknown task alias, try one of the following: ", aliases.join(', ')
|
82
57
|
exit 1
|
83
58
|
end
|
59
|
+
timer = task.start \
|
60
|
+
:starting_time => starting_time,
|
61
|
+
:note => args.join(' ')
|
62
|
+
puts "Started timer for #{timer} (at #{current_time})"
|
84
63
|
end
|
85
64
|
|
86
65
|
def stop *args
|
87
66
|
entry = DayEntry.with_timer
|
88
67
|
if entry
|
89
|
-
entry.append_note(
|
68
|
+
entry.append_note(args.join(' ')) if args.any?
|
90
69
|
entry.toggle
|
91
70
|
puts "Stopped #{entry} (at #{current_time})"
|
92
71
|
else
|
93
72
|
puts "No running timers found."
|
73
|
+
exit 1
|
94
74
|
end
|
95
75
|
end
|
96
76
|
|
@@ -102,6 +82,7 @@ module HCl
|
|
102
82
|
puts "Added note to #{entry}."
|
103
83
|
else
|
104
84
|
puts "No running timers found."
|
85
|
+
exit 1
|
105
86
|
end
|
106
87
|
end
|
107
88
|
|
@@ -118,19 +99,21 @@ module HCl
|
|
118
99
|
puts "\t#{as_hours total_hours}\ttotal (as of #{current_time})"
|
119
100
|
end
|
120
101
|
|
121
|
-
def resume
|
122
|
-
|
102
|
+
def resume *args
|
103
|
+
ident = get_ident args
|
104
|
+
entry = if ident
|
105
|
+
task_ids = get_task_ids ident, args
|
106
|
+
DayEntry.last_by_task *task_ids
|
107
|
+
else
|
108
|
+
DayEntry.last
|
109
|
+
end
|
123
110
|
if entry
|
124
|
-
puts "Resumed #{entry} (at #{current_time})"
|
125
111
|
entry.toggle
|
126
112
|
else
|
127
|
-
puts "No
|
113
|
+
puts "No matching timer found."
|
114
|
+
exit 1
|
128
115
|
end
|
129
116
|
end
|
130
117
|
|
131
|
-
private
|
132
|
-
def current_time
|
133
|
-
Time.now.strftime('%I:%M %p').downcase
|
134
|
-
end
|
135
118
|
end
|
136
119
|
end
|
data/lib/hcl/day_entry.rb
CHANGED
@@ -40,6 +40,11 @@ module HCl
|
|
40
40
|
all.detect {|t| t.running? }
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.last_by_task project_id, task_id
|
44
|
+
all.sort {|a,b| b.updated_at<=>a.updated_at}.
|
45
|
+
detect {|t| t.project_id == project_id && t.task_id == task_id }
|
46
|
+
end
|
47
|
+
|
43
48
|
def self.last
|
44
49
|
all.sort {|a,b| a.updated_at<=>b.updated_at}[-1]
|
45
50
|
end
|
data/lib/hcl/utility.rb
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
module HCl
|
2
2
|
module Utility
|
3
|
+
def get_task_ids ident, args
|
4
|
+
if @settings.key? "task.#{ident}"
|
5
|
+
@settings["task.#{ident}"].split(/\s+/)
|
6
|
+
else
|
7
|
+
[ident, args.shift]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_ident args
|
12
|
+
ident = args.detect {|a| a[0] == '@' }
|
13
|
+
if ident
|
14
|
+
args.delete(ident)
|
15
|
+
ident.slice(1..-1)
|
16
|
+
else
|
17
|
+
args.shift
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_task args
|
22
|
+
Task.find *get_task_ids(get_ident(args), args)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_starting_time args
|
26
|
+
starting_time = args.detect {|x| x =~ /^\+\d*(\.|:)?\d+$/ }
|
27
|
+
if starting_time
|
28
|
+
args.delete(starting_time)
|
29
|
+
time2float starting_time
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_time
|
34
|
+
Time.now.strftime('%I:%M %p').downcase
|
35
|
+
end
|
36
|
+
|
3
37
|
# Convert from decimal to a string of the form HH:MM.
|
4
38
|
#
|
5
39
|
# @param [#to_f] hours number of hours in decimal
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hobson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|