abt-cli 0.0.17 → 0.0.18
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/lib/abt/cli.rb +17 -17
- data/lib/abt/cli/arguments_parser.rb +4 -4
- data/lib/abt/docs.rb +9 -9
- data/lib/abt/docs/cli.rb +5 -5
- data/lib/abt/docs/markdown.rb +8 -7
- data/lib/abt/providers/asana/base_command.rb +2 -2
- data/lib/abt/providers/asana/commands/pick.rb +1 -1
- data/lib/abt/providers/asana/commands/share.rb +2 -2
- data/lib/abt/providers/devops/base_command.rb +2 -2
- data/lib/abt/providers/devops/commands/share.rb +1 -1
- data/lib/abt/providers/git/commands/branch.rb +8 -8
- data/lib/abt/providers/harvest/base_command.rb +2 -2
- data/lib/abt/providers/harvest/commands/pick.rb +1 -1
- data/lib/abt/providers/harvest/commands/share.rb +2 -2
- data/lib/abt/providers/harvest/commands/start.rb +1 -1
- data/lib/abt/providers/harvest/commands/track.rb +2 -2
- data/lib/abt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df400d04c979d979ab2ead353d68374b8266c0fff678103991cc6443512b703b
|
4
|
+
data.tar.gz: 0345141c38eae6904d11f40a3045fccd048d8009b70fe9714f5e0986f1779861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1979110cbd58f0bc71b83ad7211b86e17c5b078e842d4f99ca839c88a88d627ab92506736cd83b6e414cbea2ec2a82592f6e8b3f1effdbd2b57df7decd63793e
|
7
|
+
data.tar.gz: 6af0e9bb436b304cda9d3acf6c86733050c9a7acffb691017d968e89e3f4e8e51b9fa4cdf5e3a85373ff2f684fa61e41afce0c1b9011d2e6b5551935b40530ea
|
data/lib/abt/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module Abt
|
|
9
9
|
class Abort < StandardError; end
|
10
10
|
class Exit < StandardError; end
|
11
11
|
|
12
|
-
attr_reader :command, :
|
12
|
+
attr_reader :command, :aris, :input, :output, :err_output, :prompt
|
13
13
|
|
14
14
|
def initialize(argv: ARGV, input: STDIN, output: STDOUT, err_output: STDERR)
|
15
15
|
(@command, *remaining_args) = argv
|
@@ -18,18 +18,18 @@ module Abt
|
|
18
18
|
@err_output = err_output
|
19
19
|
@prompt = Abt::Cli::Prompt.new(output: err_output)
|
20
20
|
|
21
|
-
@
|
21
|
+
@aris = ArgumentsParser.new(sanitized_piped_args + remaining_args).parse
|
22
22
|
end
|
23
23
|
|
24
24
|
def perform
|
25
25
|
return if handle_global_commands!
|
26
26
|
|
27
|
-
abort('No
|
27
|
+
abort('No ARIs') if aris.empty?
|
28
28
|
|
29
|
-
|
29
|
+
process_aris
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def print_ari(scheme, path, description = nil)
|
33
33
|
command = "#{scheme}:#{path}"
|
34
34
|
command += " # #{description}" unless description.nil?
|
35
35
|
output.puts command
|
@@ -96,30 +96,30 @@ module Abt
|
|
96
96
|
line.split(' # ').first
|
97
97
|
end
|
98
98
|
|
99
|
-
# Allow multiple
|
100
|
-
# TODO: Force the user to pick a single
|
99
|
+
# Allow multiple ARIs on a single piped input line
|
100
|
+
# TODO: Force the user to pick a single ARI
|
101
101
|
joined_lines = lines_without_comments.join(' ').strip
|
102
102
|
joined_lines.split(/\s+/)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
def
|
106
|
+
def process_aris
|
107
107
|
used_schemes = []
|
108
|
-
|
109
|
-
scheme =
|
110
|
-
path =
|
108
|
+
aris.each do |ari|
|
109
|
+
scheme = ari.scheme
|
110
|
+
path = ari.path
|
111
111
|
|
112
112
|
if used_schemes.include?(scheme)
|
113
|
-
warn "Dropping command for already used scheme: #{
|
113
|
+
warn "Dropping command for already used scheme: #{ari}"
|
114
114
|
next
|
115
115
|
end
|
116
116
|
|
117
117
|
command_class = get_command_class(scheme)
|
118
118
|
next if command_class.nil?
|
119
119
|
|
120
|
-
print_command(command,
|
120
|
+
print_command(command, ari) if output.isatty
|
121
121
|
begin
|
122
|
-
command_class.new(path: path, cli: self, flags:
|
122
|
+
command_class.new(path: path, cli: self, flags: ari.flags).perform
|
123
123
|
rescue Exit => e
|
124
124
|
puts e.message
|
125
125
|
end
|
@@ -129,7 +129,7 @@ module Abt
|
|
129
129
|
|
130
130
|
return unless used_schemes.empty? && output.isatty
|
131
131
|
|
132
|
-
abort 'No providers found for command and
|
132
|
+
abort 'No providers found for command and ARI(s)'
|
133
133
|
end
|
134
134
|
|
135
135
|
def get_command_class(scheme)
|
@@ -139,8 +139,8 @@ module Abt
|
|
139
139
|
provider.command_class(command)
|
140
140
|
end
|
141
141
|
|
142
|
-
def print_command(name,
|
143
|
-
warn "===== #{name} #{
|
142
|
+
def print_command(name, ari)
|
143
|
+
warn "===== #{name} #{ari} =====".upcase
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Abt
|
4
4
|
class Cli
|
5
5
|
class ArgumentsParser
|
6
|
-
class
|
6
|
+
class Ari
|
7
7
|
attr_reader :scheme, :path, :flags
|
8
8
|
|
9
9
|
def initialize(scheme:, path:, flags:)
|
@@ -19,7 +19,7 @@ module Abt
|
|
19
19
|
[str, *flags].join(' ')
|
20
20
|
end
|
21
21
|
end
|
22
|
-
class
|
22
|
+
class Aris < Array
|
23
23
|
def to_s
|
24
24
|
map(&:to_s).join(' -- ')
|
25
25
|
end
|
@@ -32,14 +32,14 @@ module Abt
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def parse
|
35
|
-
result =
|
35
|
+
result = Aris.new
|
36
36
|
rest = arguments.dup
|
37
37
|
|
38
38
|
until rest.empty?
|
39
39
|
(scheme, path) = rest.shift.split(':')
|
40
40
|
flags = take_flags(rest)
|
41
41
|
|
42
|
-
result <<
|
42
|
+
result << Ari.new(scheme: scheme, path: path, flags: flags)
|
43
43
|
end
|
44
44
|
|
45
45
|
result
|
data/lib/abt/docs.rb
CHANGED
@@ -10,11 +10,11 @@ module Abt
|
|
10
10
|
def basic_examples
|
11
11
|
{
|
12
12
|
'Getting started:' => {
|
13
|
-
'abt init asana harvest' => 'Setup asana and harvest project git repo
|
14
|
-
'abt pick harvest' => 'Pick harvest
|
15
|
-
'abt pick asana | abt start harvest' => 'Pick asana task and start
|
13
|
+
'abt init asana harvest' => 'Setup asana and harvest project for local git repo',
|
14
|
+
'abt pick harvest' => 'Pick harvest task. This will likely stay the same throughout the project',
|
15
|
+
'abt pick asana | abt start harvest' => 'Pick asana task and start tracking time',
|
16
16
|
'abt stop harvest' => 'Stop time tracker',
|
17
|
-
'abt start asana harvest' => 'Continue working, e.g
|
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
20
|
}
|
@@ -22,11 +22,11 @@ module Abt
|
|
22
22
|
|
23
23
|
def extended_examples
|
24
24
|
{
|
25
|
-
'Tracking meetings (without
|
25
|
+
'Tracking meetings (without switching current task setting):' => {
|
26
26
|
'abt pick asana -d | abt track harvest' => 'Track on asana meeting task',
|
27
27
|
'abt pick harvest -d | abt track harvest -c "Name of meeting"' => 'Track on separate harvest-task'
|
28
28
|
},
|
29
|
-
'Command output can be piped
|
29
|
+
'Command output can be piped:' => {
|
30
30
|
'abt tasks asana | grep -i <name of task>' => nil,
|
31
31
|
'abt tasks asana | grep -i <name of task> | abt start' => nil
|
32
32
|
},
|
@@ -36,9 +36,9 @@ module Abt
|
|
36
36
|
'abt start <shared configuration>' => 'Start a shared configuration'
|
37
37
|
},
|
38
38
|
'Flags:' => {
|
39
|
-
'abt start harvest -c "comment"' => 'Add command flags after
|
40
|
-
'abt start harvest -c "comment" -- asana' => 'Use -- to
|
41
|
-
'abt pick harvest | abt start -c "comment"' => 'Flags placed directly after a command applies to piped in
|
39
|
+
'abt start harvest -c "comment"' => 'Add command flags after ARIs',
|
40
|
+
'abt start harvest -c "comment" -- asana' => 'Use -- to end a list of flags, so that it can be followed by another ARI',
|
41
|
+
'abt pick harvest | abt start -c "comment"' => 'Flags placed directly after a command applies to the piped in ARI'
|
42
42
|
}
|
43
43
|
}
|
44
44
|
end
|
data/lib/abt/docs/cli.rb
CHANGED
@@ -8,10 +8,10 @@ module Abt
|
|
8
8
|
<<~TXT
|
9
9
|
Usage: #{usage_line}
|
10
10
|
|
11
|
-
<command>
|
12
|
-
<
|
13
|
-
|
14
|
-
<options>
|
11
|
+
<command> Name of command to execute, e.g. start, finalize etc.
|
12
|
+
<ARI> A URI-like resource identifier with a scheme and an optional path
|
13
|
+
in the format: <scheme>[:<path>]. E.g., harvest:11111111/22222222
|
14
|
+
<options> Optional flags for the command and ARI
|
15
15
|
|
16
16
|
#{formatted_examples(Docs.basic_examples)}
|
17
17
|
|
@@ -45,7 +45,7 @@ module Abt
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def usage_line
|
48
|
-
'abt <command> [<
|
48
|
+
'abt <command> [<ARI>] [<options> --] [<ARI>] ...'
|
49
49
|
end
|
50
50
|
|
51
51
|
def formatted_examples(example_groups)
|
data/lib/abt/docs/markdown.rb
CHANGED
@@ -15,27 +15,28 @@ module Abt
|
|
15
15
|
|
16
16
|
## How does abt work?
|
17
17
|
|
18
|
-
Abt
|
18
|
+
Abt is a hybrid af having small scripts each doing one thing:
|
19
19
|
- `start-asana --project-gid xxxx --task-gid yyyy`
|
20
20
|
- `start-harvest --project-id aaaa --task-id bbbb`
|
21
21
|
|
22
|
-
And having a single highly advanced script that does everything:
|
22
|
+
And having a single highly advanced script that does everything with a single command:
|
23
23
|
- `start xxxx/yyyy aaaa/bbbb`
|
24
24
|
|
25
|
-
Abt looks like one
|
25
|
+
Abt looks like one command, but works like a bunch of light scripts:
|
26
26
|
- `abt start asana:xxxx/yyyy harvest:aaaa/bbbb`
|
27
27
|
|
28
28
|
## Usage
|
29
|
-
`abt <command> [<
|
29
|
+
`abt <command> [<ARI>] [<options> --] [<ARI>] ...`
|
30
30
|
|
31
31
|
Definitions:
|
32
32
|
- `<command>`: Name of command to execute, e.g. `start`, `finalize` etc.
|
33
|
-
- `<
|
34
|
-
- `<options>`: Optional flags for the command and
|
33
|
+
- `<ARI>`: A URI-like resource identifier with a scheme and an optional path in the format: `<scheme>[:<path>]`. E.g., `harvest:11111111/22222222`
|
34
|
+
- `<options>`: Optional flags for the command and ARI
|
35
35
|
|
36
36
|
#{example_commands}
|
37
37
|
|
38
|
-
##
|
38
|
+
## Commands:
|
39
|
+
|
39
40
|
Some commands have `[options]`. Run such a command with `--help` flag to view supported flags, e.g: `abt track harvest -h`
|
40
41
|
|
41
42
|
#{provider_commands}
|
@@ -36,13 +36,13 @@ module Abt
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def print_project(project)
|
39
|
-
cli.
|
39
|
+
cli.print_ari('asana', project['gid'], project['name'])
|
40
40
|
cli.warn project['permalink_url'] if project.key?('permalink_url') && cli.output.isatty
|
41
41
|
end
|
42
42
|
|
43
43
|
def print_task(project, task)
|
44
44
|
project = { 'gid' => project } if project.is_a?(String)
|
45
|
-
cli.
|
45
|
+
cli.print_ari('asana', "#{project['gid']}/#{task['gid']}", task['name'])
|
46
46
|
cli.warn task['permalink_url'] if task.key?('permalink_url') && cli.output.isatty
|
47
47
|
end
|
48
48
|
|
@@ -31,7 +31,7 @@ module Abt
|
|
31
31
|
|
32
32
|
return if flags[:"dry-run"]
|
33
33
|
|
34
|
-
config.project_gid = project_gid # We might have gotten the project ID
|
34
|
+
config.project_gid = project_gid # We might have gotten the project ID from a path
|
35
35
|
config.task_gid = task['gid']
|
36
36
|
end
|
37
37
|
|
@@ -17,9 +17,9 @@ module Abt
|
|
17
17
|
require_project!
|
18
18
|
|
19
19
|
if task_gid.nil?
|
20
|
-
cli.
|
20
|
+
cli.print_ari('asana', project_gid)
|
21
21
|
else
|
22
|
-
cli.
|
22
|
+
cli.print_ari('asana', "#{project_gid}/#{task_gid}")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -56,14 +56,14 @@ module Abt
|
|
56
56
|
def print_board(organization_name, project_name, board)
|
57
57
|
path = "#{organization_name}/#{project_name}/#{board['id']}"
|
58
58
|
|
59
|
-
cli.
|
59
|
+
cli.print_ari('devops', path, board['name'])
|
60
60
|
# cli.warn board['url'] if board.key?('url') && cli.output.isatty # TODO: Web URL
|
61
61
|
end
|
62
62
|
|
63
63
|
def print_work_item(organization, project, board, work_item)
|
64
64
|
path = "#{organization}/#{project}/#{board['id']}/#{work_item['id']}"
|
65
65
|
|
66
|
-
cli.
|
66
|
+
cli.print_ari('devops', path, work_item['name'])
|
67
67
|
cli.warn work_item['url'] if work_item.key?('url') && cli.output.isatty
|
68
68
|
end
|
69
69
|
|
@@ -39,29 +39,29 @@ module Abt
|
|
39
39
|
|
40
40
|
def branch_name # rubocop:disable Metrics/MethodLength
|
41
41
|
@branch_name ||= begin
|
42
|
-
if
|
42
|
+
if branch_names_from_aris.empty?
|
43
43
|
cli.abort [
|
44
|
-
'None of the specified
|
44
|
+
'None of the specified ARIs responded to `branch-name`.',
|
45
45
|
'Did you add compatible scheme? e.g.:',
|
46
46
|
' abt branch git asana',
|
47
47
|
' abt branch git devops'
|
48
48
|
].join("\n")
|
49
49
|
end
|
50
50
|
|
51
|
-
if
|
51
|
+
if branch_names_from_aris.length > 1
|
52
52
|
cli.abort [
|
53
|
-
'Got branch names from multiple
|
53
|
+
'Got branch names from multiple ARIs, only one is supported',
|
54
54
|
'Branch names were:',
|
55
|
-
*
|
55
|
+
*branch_names_from_aris.map { |name| " #{name}" }
|
56
56
|
].join("\n")
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
branch_names_from_aris.first
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
64
|
-
input = StringIO.new(cli.
|
63
|
+
def branch_names_from_aris
|
64
|
+
input = StringIO.new(cli.aris.to_s)
|
65
65
|
output = StringIO.new
|
66
66
|
Abt::Cli.new(argv: ['branch-name'], output: output, input: input).perform
|
67
67
|
|
@@ -36,7 +36,7 @@ module Abt
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def print_project(project)
|
39
|
-
cli.
|
39
|
+
cli.print_ari(
|
40
40
|
'harvest',
|
41
41
|
project['id'],
|
42
42
|
"#{project['client']['name']} > #{project['name']}"
|
@@ -44,7 +44,7 @@ module Abt
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def print_task(project, task)
|
47
|
-
cli.
|
47
|
+
cli.print_ari(
|
48
48
|
'harvest',
|
49
49
|
"#{project['id']}/#{task['id']}",
|
50
50
|
"#{project['name']} > #{task['name']}"
|
@@ -17,9 +17,9 @@ module Abt
|
|
17
17
|
if project_id.nil?
|
18
18
|
cli.warn 'No project selected'
|
19
19
|
elsif task_id.nil?
|
20
|
-
cli.
|
20
|
+
cli.print_ari('harvest', project_id)
|
21
21
|
else
|
22
|
-
cli.
|
22
|
+
cli.print_ari('harvest', "#{project_id}/#{task_id}")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -12,7 +12,7 @@ module Abt
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.description
|
15
|
-
'Alias for: `abt track harvest`. Meant to used in combination with other
|
15
|
+
'Alias for: `abt track harvest`. Meant to used in combination with other ARIs, e.g. `abt start harvest asana`'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -10,7 +10,7 @@ module Abt
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.description
|
13
|
-
'Start tracker for current or specified task. Add a relevant
|
13
|
+
'Start tracker for current or specified task. Add a relevant ARI to link the time entry, e.g. `abt track harvest asana`'
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.flags
|
@@ -77,7 +77,7 @@ module Abt
|
|
77
77
|
|
78
78
|
def external_link_data
|
79
79
|
@external_link_data ||= begin
|
80
|
-
input = StringIO.new(cli.
|
80
|
+
input = StringIO.new(cli.aris.to_s)
|
81
81
|
output = StringIO.new
|
82
82
|
Abt::Cli.new(argv: ['harvest-time-entry-data'], output: output, input: input).perform
|
83
83
|
|
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.18
|
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-02-
|
11
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|