toggl_cli 1.2.0 → 1.3.0
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/bin/toggl_cli +16 -5
- data/lib/toggl_cli.rb +63 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fc24cda91244babd028aad50e489902d8439d09ff28732c9b30542400cb8874
|
4
|
+
data.tar.gz: d954b78521ee467b2306ee3398352aaa897fb98d7d91625cae7802f5b7a94841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0bb0404cdfc0cc5124da5712bc51a693469ca8cb40b899de8b58cf55276e7f43171599cce565d33e141d3ba0ae1f27e4a00875505c3076cc05592984dbc88df
|
7
|
+
data.tar.gz: 1e608760d907149ea455ce3d5440bf095e1480e5336788f20136c136df5b88c4fc10057ff5a46a1a07a6e5cf6641d85e0b496b90417b31da9748674737a0e469
|
data/bin/toggl_cli
CHANGED
@@ -12,17 +12,28 @@ end
|
|
12
12
|
|
13
13
|
case command
|
14
14
|
when 'start'
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
client = ARGV[1]
|
16
|
+
project = ARGV[2]
|
17
|
+
description = ARGV[3]
|
18
|
+
@toggl_cli.start(client, project, description)
|
18
19
|
puts "Timer Started"
|
19
20
|
when 'stop'
|
20
21
|
result = @toggl_cli.stop
|
21
22
|
duration = (result['duration'].to_i / 60.0).round(2)
|
22
23
|
puts "Timer Stopped. Duration: #{duration} minutes."
|
23
24
|
when 'today'
|
24
|
-
|
25
|
-
|
25
|
+
client = ARGV[1]
|
26
|
+
result = @toggl_cli.today(client)
|
27
|
+
puts result[:entries]
|
28
|
+
puts "You have logged #{result[:total]} minutes or #{(result[:total]/60.0).round(2)} hours today"
|
29
|
+
when 'clients'
|
30
|
+
result = @toggl_cli.clients
|
31
|
+
puts result
|
32
|
+
when 'projects'
|
33
|
+
result = @toggl_cli.projects
|
34
|
+
result.each do |r|
|
35
|
+
puts "#{r['id']} #{r['cid']} #{r['name']}"
|
36
|
+
end
|
26
37
|
else
|
27
38
|
puts "Uh-oh! I haven't learned that command yet"
|
28
39
|
end
|
data/lib/toggl_cli.rb
CHANGED
@@ -12,11 +12,10 @@ class TogglCLI
|
|
12
12
|
@workspace_id = @workspaces.first['id']
|
13
13
|
end
|
14
14
|
|
15
|
-
def start(project, description)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
def start(client, project, description)
|
16
|
+
cid = client(client)['id']
|
17
|
+
pid = project(cid, project)['id']
|
18
|
+
|
20
19
|
time_entry = @toggl_api.start_time_entry({
|
21
20
|
'pid' => pid,
|
22
21
|
'description' => "#{description}",
|
@@ -33,7 +32,18 @@ class TogglCLI
|
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
def today
|
35
|
+
def today(client = nil, project = nil)
|
36
|
+
pids = []
|
37
|
+
if client
|
38
|
+
cid = client(client)['id']
|
39
|
+
presult = projects
|
40
|
+
presult.each do |r|
|
41
|
+
if r['cid'] == cid
|
42
|
+
pids << r['id']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
entries = []
|
37
47
|
dates = {
|
38
48
|
start_date: Time.parse(Date.today.to_s).to_s,
|
39
49
|
end_date: Time.now.to_s
|
@@ -41,8 +51,53 @@ class TogglCLI
|
|
41
51
|
total = 0
|
42
52
|
result = @toggl_api.get_time_entries(dates)
|
43
53
|
result.each do |r|
|
44
|
-
|
54
|
+
if (client && (pids.include? r['pid']))
|
55
|
+
entries << "#{r['duration']} - #{r['description']}"
|
56
|
+
total = total + r['duration']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
{entries: entries, total: (total / 60.0).round(2)}
|
60
|
+
end
|
61
|
+
|
62
|
+
def clients
|
63
|
+
clients = []
|
64
|
+
result = @toggl_api.my_clients
|
65
|
+
result.each do |r|
|
66
|
+
clients << "#{r['id']} #{r['name']}"
|
67
|
+
end
|
68
|
+
clients
|
69
|
+
end
|
70
|
+
|
71
|
+
def client(name)
|
72
|
+
client = ""
|
73
|
+
result = @toggl_api.my_clients
|
74
|
+
result.each do |r|
|
75
|
+
if r['name'].downcase == name
|
76
|
+
client = r
|
77
|
+
end
|
78
|
+
end
|
79
|
+
client
|
80
|
+
end
|
81
|
+
|
82
|
+
def projects(client_id = nil)
|
83
|
+
projects = []
|
84
|
+
result = @toggl_api.my_projects
|
85
|
+
result.each do |r|
|
86
|
+
if r['cid']
|
87
|
+
projects << r
|
88
|
+
end
|
89
|
+
end
|
90
|
+
projects
|
91
|
+
end
|
92
|
+
|
93
|
+
def project(client_id, name)
|
94
|
+
project = ""
|
95
|
+
result = @toggl_api.my_projects
|
96
|
+
result.each do |r|
|
97
|
+
if r['cid'] == client_id && r['name'].downcase == name
|
98
|
+
project = r
|
99
|
+
end
|
45
100
|
end
|
46
|
-
|
101
|
+
project
|
47
102
|
end
|
48
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toggl_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Erickson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: togglv8
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
|
-
rubygems_version: 3.0.
|
55
|
+
rubygems_version: 3.0.3
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: A simple command line tool for toggl
|