abt-cli 0.0.18 → 0.0.19
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/ari.rb +20 -0
- data/lib/abt/ari_list.rb +13 -0
- data/lib/abt/base_command.rb +63 -0
- data/lib/abt/cli.rb +6 -9
- data/lib/abt/cli/arguments_parser.rb +1 -23
- data/lib/abt/cli/prompt.rb +5 -4
- data/lib/abt/docs.rb +6 -5
- data/lib/abt/docs/markdown.rb +1 -1
- data/lib/abt/git_config.rb +20 -36
- data/lib/abt/providers/asana/base_command.rb +13 -33
- data/lib/abt/providers/asana/commands/add.rb +9 -7
- data/lib/abt/providers/asana/commands/branch_name.rb +9 -4
- data/lib/abt/providers/asana/commands/clear.rb +2 -0
- data/lib/abt/providers/asana/commands/current.rb +19 -34
- data/lib/abt/providers/asana/commands/finalize.rb +3 -3
- data/lib/abt/providers/asana/commands/harvest_time_entry_data.rb +9 -4
- data/lib/abt/providers/asana/commands/init.rb +6 -6
- data/lib/abt/providers/asana/commands/pick.rb +16 -11
- data/lib/abt/providers/asana/commands/projects.rb +1 -1
- data/lib/abt/providers/asana/commands/share.rb +2 -6
- data/lib/abt/providers/asana/commands/start.rb +14 -12
- data/lib/abt/providers/asana/commands/tasks.rb +4 -3
- data/lib/abt/providers/asana/configuration.rb +18 -24
- data/lib/abt/providers/asana/path.rb +36 -0
- data/lib/abt/providers/devops/api.rb +12 -0
- data/lib/abt/providers/devops/base_command.rb +13 -38
- data/lib/abt/providers/devops/commands/boards.rb +2 -2
- data/lib/abt/providers/devops/commands/branch_name.rb +7 -3
- data/lib/abt/providers/devops/commands/clear.rb +2 -0
- data/lib/abt/providers/devops/commands/current.rb +14 -38
- data/lib/abt/providers/devops/commands/harvest_time_entry_data.rb +9 -1
- data/lib/abt/providers/devops/commands/init.rb +15 -15
- data/lib/abt/providers/devops/commands/pick.rb +5 -12
- data/lib/abt/providers/devops/commands/share.rb +3 -4
- data/lib/abt/providers/devops/commands/work-items.rb +1 -1
- data/lib/abt/providers/devops/configuration.rb +17 -46
- data/lib/abt/providers/devops/path.rb +50 -0
- data/lib/abt/providers/git/commands/branch.rb +14 -8
- data/lib/abt/providers/harvest/base_command.rb +14 -32
- data/lib/abt/providers/harvest/commands/clear.rb +2 -0
- data/lib/abt/providers/harvest/commands/current.rb +24 -31
- data/lib/abt/providers/harvest/commands/init.rb +5 -6
- data/lib/abt/providers/harvest/commands/pick.rb +3 -4
- data/lib/abt/providers/harvest/commands/projects.rb +1 -1
- data/lib/abt/providers/harvest/commands/share.rb +4 -8
- data/lib/abt/providers/harvest/commands/stop.rb +7 -7
- data/lib/abt/providers/harvest/commands/tasks.rb +4 -1
- data/lib/abt/providers/harvest/commands/track.rb +25 -18
- data/lib/abt/providers/harvest/configuration.rb +20 -29
- data/lib/abt/providers/harvest/path.rb +36 -0
- data/lib/abt/version.rb +1 -1
- metadata +8 -3
- data/lib/abt/cli/base_command.rb +0 -61
@@ -8,32 +8,18 @@ module Abt
|
|
8
8
|
|
9
9
|
def initialize(cli:)
|
10
10
|
@cli = cli
|
11
|
-
@git = GitConfig.new(namespace: 'abt.harvest')
|
12
11
|
end
|
13
12
|
|
14
13
|
def local_available?
|
15
|
-
|
14
|
+
git.available?
|
16
15
|
end
|
17
16
|
|
18
|
-
def
|
19
|
-
local_available?
|
17
|
+
def path
|
18
|
+
Path.new(local_available? && git['path'] || '')
|
20
19
|
end
|
21
20
|
|
22
|
-
def
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def project_id=(value)
|
27
|
-
value = value.to_s unless value.nil?
|
28
|
-
return if project_id == value
|
29
|
-
|
30
|
-
clear_local(verbose: false)
|
31
|
-
git['projectId'] = value
|
32
|
-
end
|
33
|
-
|
34
|
-
def task_id=(value)
|
35
|
-
value = value.to_s unless value.nil?
|
36
|
-
git['taskId'] = value
|
21
|
+
def path=(new_path)
|
22
|
+
git['path'] = new_path
|
37
23
|
end
|
38
24
|
|
39
25
|
def clear_local(verbose: true)
|
@@ -41,13 +27,13 @@ module Abt
|
|
41
27
|
end
|
42
28
|
|
43
29
|
def clear_global(verbose: true)
|
44
|
-
|
30
|
+
git_global.clear(output: verbose ? cli.err_output : nil)
|
45
31
|
end
|
46
32
|
|
47
33
|
def access_token
|
48
|
-
return
|
34
|
+
return git_global['accessToken'] unless git_global['accessToken'].nil?
|
49
35
|
|
50
|
-
|
36
|
+
git_global['accessToken'] = cli.prompt.text([
|
51
37
|
'Please provide your personal access token for Harvest.',
|
52
38
|
'If you don\'t have one, create one here: https://id.getharvest.com/developers',
|
53
39
|
'',
|
@@ -56,9 +42,9 @@ module Abt
|
|
56
42
|
end
|
57
43
|
|
58
44
|
def account_id
|
59
|
-
return
|
45
|
+
return git_global['accountId'] unless git_global['accountId'].nil?
|
60
46
|
|
61
|
-
|
47
|
+
git_global['accountId'] = cli.prompt.text([
|
62
48
|
'Please provide harvest account id.',
|
63
49
|
'This information is shown next to your generated access token',
|
64
50
|
'',
|
@@ -67,18 +53,23 @@ module Abt
|
|
67
53
|
end
|
68
54
|
|
69
55
|
def user_id
|
70
|
-
return
|
56
|
+
return git_global['userId'] unless git_global['userId'].nil?
|
71
57
|
|
72
|
-
|
58
|
+
git_global['userId'] = api.get('users/me')['id'].to_s
|
73
59
|
end
|
74
60
|
|
75
61
|
private
|
76
62
|
|
77
|
-
|
63
|
+
def git
|
64
|
+
@git ||= GitConfig.new('local', 'abt.harvest')
|
65
|
+
end
|
66
|
+
|
67
|
+
def git_global
|
68
|
+
@git_global ||= GitConfig.new('global', 'abt.harvest')
|
69
|
+
end
|
78
70
|
|
79
71
|
def api
|
80
|
-
@api ||=
|
81
|
-
Abt::Providers::Harvest::Api.new(access_token: access_token, account_id: account_id)
|
72
|
+
@api ||= Api.new(access_token: access_token, account_id: account_id)
|
82
73
|
end
|
83
74
|
end
|
84
75
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
module Providers
|
5
|
+
module Harvest
|
6
|
+
class Path < String
|
7
|
+
PATH_REGEX = %r{^(?<project_id>\d+)?(/(?<task_id>\d+))?$}.freeze
|
8
|
+
|
9
|
+
def self.from_ids(project_id = nil, task_id = nil)
|
10
|
+
path = project_id ? [project_id, *task_id].join('/') : ''
|
11
|
+
new path
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(path = '')
|
15
|
+
raise Abt::Cli::Abort, "Invalid path: #{path}" unless path =~ PATH_REGEX
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def project_id
|
21
|
+
match[:project_id]
|
22
|
+
end
|
23
|
+
|
24
|
+
def task_id
|
25
|
+
match[:task_id]
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def match
|
31
|
+
@match ||= PATH_REGEX.match(self)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.19
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -75,9 +75,11 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- "./lib/abt.rb"
|
78
|
+
- "./lib/abt/ari.rb"
|
79
|
+
- "./lib/abt/ari_list.rb"
|
80
|
+
- "./lib/abt/base_command.rb"
|
78
81
|
- "./lib/abt/cli.rb"
|
79
82
|
- "./lib/abt/cli/arguments_parser.rb"
|
80
|
-
- "./lib/abt/cli/base_command.rb"
|
81
83
|
- "./lib/abt/cli/prompt.rb"
|
82
84
|
- "./lib/abt/docs.rb"
|
83
85
|
- "./lib/abt/docs/cli.rb"
|
@@ -102,6 +104,7 @@ files:
|
|
102
104
|
- "./lib/abt/providers/asana/commands/start.rb"
|
103
105
|
- "./lib/abt/providers/asana/commands/tasks.rb"
|
104
106
|
- "./lib/abt/providers/asana/configuration.rb"
|
107
|
+
- "./lib/abt/providers/asana/path.rb"
|
105
108
|
- "./lib/abt/providers/devops.rb"
|
106
109
|
- "./lib/abt/providers/devops/api.rb"
|
107
110
|
- "./lib/abt/providers/devops/base_command.rb"
|
@@ -115,6 +118,7 @@ files:
|
|
115
118
|
- "./lib/abt/providers/devops/commands/share.rb"
|
116
119
|
- "./lib/abt/providers/devops/commands/work-items.rb"
|
117
120
|
- "./lib/abt/providers/devops/configuration.rb"
|
121
|
+
- "./lib/abt/providers/devops/path.rb"
|
118
122
|
- "./lib/abt/providers/git.rb"
|
119
123
|
- "./lib/abt/providers/git/commands/branch.rb"
|
120
124
|
- "./lib/abt/providers/harvest.rb"
|
@@ -131,6 +135,7 @@ files:
|
|
131
135
|
- "./lib/abt/providers/harvest/commands/tasks.rb"
|
132
136
|
- "./lib/abt/providers/harvest/commands/track.rb"
|
133
137
|
- "./lib/abt/providers/harvest/configuration.rb"
|
138
|
+
- "./lib/abt/providers/harvest/path.rb"
|
134
139
|
- "./lib/abt/version.rb"
|
135
140
|
- bin/abt
|
136
141
|
homepage: https://github.com/abtion/abt
|
data/lib/abt/cli/base_command.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Abt
|
4
|
-
class Cli
|
5
|
-
class BaseCommand
|
6
|
-
def self.usage
|
7
|
-
raise NotImplementedError, 'Command classes must implement .command'
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.description
|
11
|
-
raise NotImplementedError, 'Command classes must implement .description'
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.flags
|
15
|
-
[]
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_reader :path, :flags, :cli
|
19
|
-
|
20
|
-
def initialize(path:, flags:, cli:)
|
21
|
-
@cli = cli
|
22
|
-
@path = path
|
23
|
-
@flags = parse_flags(flags)
|
24
|
-
end
|
25
|
-
|
26
|
-
def perform
|
27
|
-
raise NotImplementedError, 'Command classes must implement #perform'
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def parse_flags(flags)
|
33
|
-
result = {}
|
34
|
-
|
35
|
-
flag_parser.parse!(flags.dup, into: result)
|
36
|
-
|
37
|
-
cli.exit_with_message(flag_parser.help) if result[:help]
|
38
|
-
|
39
|
-
result
|
40
|
-
rescue OptionParser::InvalidOption => e
|
41
|
-
cli.abort e.message
|
42
|
-
end
|
43
|
-
|
44
|
-
def flag_parser
|
45
|
-
@flag_parser ||= OptionParser.new do |opts|
|
46
|
-
opts.banner = <<~TXT
|
47
|
-
#{self.class.description}
|
48
|
-
|
49
|
-
Usage: #{self.class.usage}
|
50
|
-
TXT
|
51
|
-
|
52
|
-
opts.on('-h', '--help')
|
53
|
-
|
54
|
-
self.class.flags.each do |(*flag)|
|
55
|
-
opts.on(*flag)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|