abt-cli 0.0.7 → 0.0.8
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/abt +1 -0
- data/lib/abt/docs.rb +4 -0
- data/lib/abt/providers/harvest/commands/start.rb +22 -65
- data/lib/abt/providers/harvest/commands/track.rb +70 -0
- data/lib/abt/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3568d2d1acd067392e3832ee00bb1eb6f1fdcb6d9526fe1f747674c452173543
|
4
|
+
data.tar.gz: f189b4c27d9cac1703211dc4c9fefdd33d359149d336d74f67f47aa9e9d96137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c38b239739f77fd58ce6df48e7f4057fb66a1a50f96bb2d7469ef7b0809b085d643face8fdbc82f9bb654ea75e565f60e9629952f9cc894abe9745101fd670bb
|
7
|
+
data.tar.gz: f5fdf894aba1ca64f7a815f7aa1e17d2c23e3c690220f54b4cd0351586c293fd7a5716dbac544c9a63be6fb6ea8154e9e53c2e76658406e67f95656c597ab4f6
|
data/bin/abt
CHANGED
data/lib/abt/docs.rb
CHANGED
@@ -17,6 +17,10 @@ module Abt
|
|
17
17
|
'abt start asana harvest' => 'Continue working, e.g. after a break',
|
18
18
|
'abt finalize asana' => 'Finalize the selected asana task'
|
19
19
|
},
|
20
|
+
'Tracking meetings (without changing the config):' => {
|
21
|
+
'abt tasks asana | grep -i standup | abt track harvest' => 'Track on asana meeting task without changing any configuration',
|
22
|
+
'abt tasks harvest | grep -i comment | abt track harvest' => 'Track on harvest "Comment"-task (will prompt for a comment)'
|
23
|
+
},
|
20
24
|
'Command output can be piped, e.g.:' => {
|
21
25
|
'abt tasks asana | grep -i <name of task>' => nil,
|
22
26
|
'abt tasks asana | grep -i <name of task> | abt start' => nil
|
@@ -10,21 +10,16 @@ module Abt
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.description
|
13
|
-
'
|
13
|
+
'As track, but also lets the user override the current task and triggers `start` commands for other providers ' # rubocop:disable Layout/LineLength
|
14
14
|
end
|
15
15
|
|
16
16
|
def call
|
17
|
-
|
17
|
+
start_output = call_start
|
18
|
+
puts start_output
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
print_task(project, task)
|
22
|
-
|
23
|
-
cli.abort('No task selected') if task_id.nil?
|
24
|
-
|
25
|
-
create_time_entry
|
20
|
+
use_arg_str(arg_str_from_start_output(start_output))
|
26
21
|
|
27
|
-
|
22
|
+
maybe_override_current_task
|
28
23
|
rescue Abt::HttpError::HttpError => e
|
29
24
|
cli.warn e
|
30
25
|
cli.abort 'Unable to start tracker'
|
@@ -32,67 +27,29 @@ module Abt
|
|
32
27
|
|
33
28
|
private
|
34
29
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
return unless config.local_available?
|
39
|
-
|
40
|
-
should_override = cli.prompt_boolean 'Set selected task as current?'
|
41
|
-
Current.new(arg_str: arg_str, cli: cli).call if should_override
|
30
|
+
def arg_str_from_start_output(output)
|
31
|
+
output = output.split(' # ').first
|
32
|
+
output.split(':')[1]
|
42
33
|
end
|
43
34
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
task_id: task_id,
|
48
|
-
user_id: config.user_id,
|
49
|
-
spent_date: Date.today.iso8601
|
50
|
-
}
|
51
|
-
|
52
|
-
if external_link_data
|
53
|
-
body.merge! external_link_data
|
54
|
-
else
|
55
|
-
cli.warn 'No external link provided'
|
56
|
-
body[:notes] ||= cli.prompt('Fill in comment (optional)')
|
57
|
-
end
|
58
|
-
|
59
|
-
api.post('time_entries', Oj.dump(body, mode: :json))
|
60
|
-
end
|
35
|
+
def call_start
|
36
|
+
output = StringIO.new
|
37
|
+
Abt::Cli.new(argv: ['track', *cli.args], output: output).perform
|
61
38
|
|
62
|
-
|
63
|
-
|
39
|
+
output_str = output.string.strip
|
40
|
+
cli.abort 'No task provided' if output_str.empty?
|
41
|
+
output_str
|
64
42
|
end
|
65
43
|
|
66
|
-
def
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
def project_assignment
|
73
|
-
@project_assignment ||= begin
|
74
|
-
project_assignments.find { |pa| pa['project']['id'].to_s == project_id }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def project_assignments
|
79
|
-
@project_assignments ||= api.get_paged('users/me/project_assignments')
|
80
|
-
end
|
81
|
-
|
82
|
-
def external_link_data
|
83
|
-
@external_link_data ||= begin
|
84
|
-
arg_strs = cli.args.join(' ')
|
85
|
-
lines = `#{$PROGRAM_NAME} harvest-time-entry-data #{arg_strs}`.split("\n")
|
86
|
-
|
87
|
-
return if lines.empty?
|
88
|
-
|
89
|
-
# TODO: Make user choose which reference to use by printing the urls
|
90
|
-
if lines.length > 1
|
91
|
-
cli.abort('Multiple providers had harvest reference data, only one is supported at a time') # rubocop:disable Layout/LineLength
|
92
|
-
end
|
44
|
+
def maybe_override_current_task
|
45
|
+
return if arg_str.nil?
|
46
|
+
return if same_args_as_config?
|
47
|
+
return unless config.local_available?
|
48
|
+
return unless cli.prompt_boolean 'Set selected task as current?'
|
93
49
|
|
94
|
-
|
95
|
-
|
50
|
+
output = StringIO.new
|
51
|
+
Abt::Cli.new(argv: ['current', "harvest:#{project_id}/#{task_id}"],
|
52
|
+
output: output).perform
|
96
53
|
end
|
97
54
|
end
|
98
55
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
module Providers
|
5
|
+
module Harvest
|
6
|
+
module Commands
|
7
|
+
class Track < BaseCommand
|
8
|
+
def self.command
|
9
|
+
'track harvest[:<project-id>/<task-id>]'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.description
|
13
|
+
'Start tracker for current or specified task. Add a relevant provider to link the time entry: E.g. `abt start harvest asana`' # rubocop:disable Layout/LineLength
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
abort 'No current/provided task' if task_id.nil?
|
18
|
+
cli.abort('No task selected') if task_id.nil?
|
19
|
+
|
20
|
+
print_task(created_time_entry['project'], created_time_entry['task'])
|
21
|
+
|
22
|
+
cli.warn 'Tracker successfully started'
|
23
|
+
rescue Abt::HttpError::HttpError => e
|
24
|
+
cli.abort 'Invalid task'
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def created_time_entry
|
30
|
+
@created_time_entry ||= create_time_entry
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_time_entry
|
34
|
+
body = {
|
35
|
+
project_id: project_id,
|
36
|
+
task_id: task_id,
|
37
|
+
user_id: config.user_id,
|
38
|
+
spent_date: Date.today.iso8601
|
39
|
+
}
|
40
|
+
|
41
|
+
if external_link_data
|
42
|
+
body.merge! external_link_data
|
43
|
+
else
|
44
|
+
cli.warn 'No external link provided'
|
45
|
+
body[:notes] ||= cli.prompt('Fill in comment (optional)')
|
46
|
+
end
|
47
|
+
|
48
|
+
api.post('time_entries', Oj.dump(body, mode: :json))
|
49
|
+
end
|
50
|
+
|
51
|
+
def external_link_data
|
52
|
+
@external_link_data ||= begin
|
53
|
+
arg_strs = cli.args.join(' ')
|
54
|
+
lines = `#{$PROGRAM_NAME} harvest-time-entry-data #{arg_strs}`.split("\n")
|
55
|
+
|
56
|
+
return if lines.empty?
|
57
|
+
|
58
|
+
# TODO: Make user choose which reference to use by printing the urls
|
59
|
+
if lines.length > 1
|
60
|
+
cli.abort('Multiple providers had harvest reference data, only one is supported at a time') # rubocop:disable Layout/LineLength
|
61
|
+
end
|
62
|
+
|
63
|
+
Oj.load(lines.first)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/abt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abt-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesper Sørensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- "./lib/abt/providers/harvest/commands/start.rb"
|
114
114
|
- "./lib/abt/providers/harvest/commands/stop.rb"
|
115
115
|
- "./lib/abt/providers/harvest/commands/tasks.rb"
|
116
|
+
- "./lib/abt/providers/harvest/commands/track.rb"
|
116
117
|
- "./lib/abt/providers/harvest/configuration.rb"
|
117
118
|
- "./lib/abt/version.rb"
|
118
119
|
- bin/abt
|