abt-cli 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/bin/abt +3 -3
  3. data/lib/abt.rb +6 -6
  4. data/lib/abt/ari.rb +1 -1
  5. data/lib/abt/ari_list.rb +1 -1
  6. data/lib/abt/base_command.rb +7 -7
  7. data/lib/abt/cli.rb +27 -40
  8. data/lib/abt/cli/arguments_parser.rb +5 -9
  9. data/lib/abt/cli/global_commands.rb +23 -0
  10. data/lib/abt/cli/global_commands/commands.rb +2 -2
  11. data/lib/abt/cli/global_commands/examples.rb +2 -2
  12. data/lib/abt/cli/global_commands/help.rb +2 -2
  13. data/lib/abt/cli/global_commands/readme.rb +2 -2
  14. data/lib/abt/cli/global_commands/share.rb +6 -6
  15. data/lib/abt/cli/global_commands/version.rb +2 -2
  16. data/lib/abt/cli/prompt.rb +51 -20
  17. data/lib/abt/docs.rb +39 -33
  18. data/lib/abt/docs/cli.rb +3 -3
  19. data/lib/abt/docs/markdown.rb +5 -5
  20. data/lib/abt/git_config.rb +4 -6
  21. data/lib/abt/providers/asana/api.rb +9 -9
  22. data/lib/abt/providers/asana/base_command.rb +8 -10
  23. data/lib/abt/providers/asana/commands/add.rb +13 -12
  24. data/lib/abt/providers/asana/commands/branch_name.rb +8 -8
  25. data/lib/abt/providers/asana/commands/clear.rb +7 -8
  26. data/lib/abt/providers/asana/commands/current.rb +14 -14
  27. data/lib/abt/providers/asana/commands/finalize.rb +11 -12
  28. data/lib/abt/providers/asana/commands/harvest_time_entry_data.rb +11 -11
  29. data/lib/abt/providers/asana/commands/init.rb +8 -41
  30. data/lib/abt/providers/asana/commands/pick.rb +17 -17
  31. data/lib/abt/providers/asana/commands/projects.rb +5 -5
  32. data/lib/abt/providers/asana/commands/share.rb +5 -5
  33. data/lib/abt/providers/asana/commands/start.rb +21 -20
  34. data/lib/abt/providers/asana/commands/tasks.rb +6 -6
  35. data/lib/abt/providers/asana/configuration.rb +25 -25
  36. data/lib/abt/providers/asana/path.rb +5 -5
  37. data/lib/abt/providers/devops/api.rb +12 -12
  38. data/lib/abt/providers/devops/base_command.rb +10 -10
  39. data/lib/abt/providers/devops/commands/boards.rb +5 -7
  40. data/lib/abt/providers/devops/commands/branch_name.rb +9 -9
  41. data/lib/abt/providers/devops/commands/clear.rb +7 -8
  42. data/lib/abt/providers/devops/commands/current.rb +17 -17
  43. data/lib/abt/providers/devops/commands/harvest_time_entry_data.rb +13 -13
  44. data/lib/abt/providers/devops/commands/init.rb +17 -13
  45. data/lib/abt/providers/devops/commands/pick.rb +11 -11
  46. data/lib/abt/providers/devops/commands/share.rb +5 -5
  47. data/lib/abt/providers/devops/commands/{work-items.rb → work_items.rb} +3 -3
  48. data/lib/abt/providers/devops/configuration.rb +19 -15
  49. data/lib/abt/providers/devops/path.rb +5 -4
  50. data/lib/abt/providers/git/commands/branch.rb +17 -19
  51. data/lib/abt/providers/harvest/api.rb +8 -8
  52. data/lib/abt/providers/harvest/base_command.rb +6 -8
  53. data/lib/abt/providers/harvest/commands/clear.rb +7 -8
  54. data/lib/abt/providers/harvest/commands/current.rb +13 -13
  55. data/lib/abt/providers/harvest/commands/init.rb +10 -38
  56. data/lib/abt/providers/harvest/commands/pick.rb +11 -11
  57. data/lib/abt/providers/harvest/commands/projects.rb +5 -5
  58. data/lib/abt/providers/harvest/commands/share.rb +5 -5
  59. data/lib/abt/providers/harvest/commands/start.rb +5 -3
  60. data/lib/abt/providers/harvest/commands/stop.rb +12 -12
  61. data/lib/abt/providers/harvest/commands/tasks.rb +7 -7
  62. data/lib/abt/providers/harvest/commands/track.rb +21 -20
  63. data/lib/abt/providers/harvest/configuration.rb +18 -18
  64. data/lib/abt/providers/harvest/path.rb +5 -5
  65. data/lib/abt/version.rb +1 -1
  66. metadata +6 -5
@@ -6,30 +6,33 @@ module Abt
6
6
  module Commands
7
7
  class Track < BaseCommand
8
8
  def self.usage
9
- 'abt track harvest[:<project-id>/<task-id>] [options]'
9
+ "abt track harvest[:<project-id>/<task-id>] [options]"
10
10
  end
11
11
 
12
12
  def self.description
13
- 'Start tracker for current or specified task. Add a relevant ARI to link the time entry, e.g. `abt track harvest asana`'
13
+ <<~TXT
14
+ Start tracker for current or specified task. Add a relevant ARI to link the time entry, e.g. `abt track harvest asana`
15
+ TXT
14
16
  end
15
17
 
16
18
  def self.flags
17
19
  [
18
- ['-s', '--set', 'Set specified task as current'],
19
- ['-c', '--comment COMMENT', 'Override comment'],
20
- ['-t', '--time HOURS', 'Set hours. Creates a stopped entry unless used with --running'],
21
- ['-r', '--running', 'Used with --time, starts the created time entry']
20
+ ["-s", "--set", "Set specified task as current"],
21
+ ["-c", "--comment COMMENT", "Override comment"],
22
+ ["-t", "--time HOURS",
23
+ "Set hours. Creates a stopped entry unless used with --running"],
24
+ ["-r", "--running", "Used with --time, starts the created time entry"]
22
25
  ]
23
26
  end
24
27
 
25
28
  def perform
26
29
  require_task!
27
30
 
28
- print_task(created_time_entry['project'], created_time_entry['task'])
31
+ print_task(created_time_entry["project"], created_time_entry["task"])
29
32
 
30
33
  maybe_override_current_task
31
34
  rescue Abt::HttpError::HttpError => _e
32
- abort 'Invalid task'
35
+ abort("Invalid task")
33
36
  end
34
37
 
35
38
  private
@@ -40,13 +43,11 @@ module Abt
40
43
 
41
44
  def create_time_entry
42
45
  body = time_entry_base_data
43
- body.merge!(hours: flags[:time]) if flags.key? :time
46
+ body[:hours] = flags[:time] if flags.key?(:time)
44
47
 
45
- result = api.post('time_entries', Oj.dump(body, mode: :json))
48
+ result = api.post("time_entries", Oj.dump(body, mode: :json))
46
49
 
47
- if flags.key?(:time) && flags[:running]
48
- api.patch("time_entries/#{result['id']}/restart")
49
- end
50
+ api.patch("time_entries/#{result['id']}/restart") if flags.key?(:time) && flags[:running]
50
51
 
51
52
  result
52
53
  end
@@ -60,18 +61,18 @@ module Abt
60
61
  }
61
62
 
62
63
  if external_link_data
63
- warn <<~TXT
64
+ warn(<<~TXT)
64
65
  Linking to:
65
66
  #{external_link_data[:notes]}
66
67
  #{external_link_data[:external_reference][:permalink]}
67
68
  TXT
68
- body.merge! external_link_data
69
+ body.merge!(external_link_data)
69
70
  else
70
- warn 'No external link provided'
71
+ warn("No external link provided")
71
72
  end
72
73
 
73
74
  body[:notes] = flags[:comment] if flags.key?(:comment)
74
- body[:notes] ||= cli.prompt.text('Fill in comment (optional)')
75
+ body[:notes] ||= cli.prompt.text("Fill in comment (optional)")
75
76
  body
76
77
  end
77
78
 
@@ -83,7 +84,7 @@ module Abt
83
84
  nil
84
85
  else
85
86
  if lines.length > 1
86
- abort('Got reference data from multiple scheme providers, only one is supported at a time')
87
+ abort("Got reference data from multiple scheme providers, only one is supported at a time")
87
88
  end
88
89
 
89
90
  Oj.load(lines.first, symbol_keys: true)
@@ -97,7 +98,7 @@ module Abt
97
98
 
98
99
  input = StringIO.new(other_aris.to_s)
99
100
  output = StringIO.new
100
- Abt::Cli.new(argv: ['harvest-time-entry-data'], output: output, input: input).perform
101
+ Abt::Cli.new(argv: ["harvest-time-entry-data"], output: output, input: input).perform
101
102
 
102
103
  output.string.strip.lines
103
104
  end
@@ -108,7 +109,7 @@ module Abt
108
109
  return unless config.local_available?
109
110
 
110
111
  config.path = path
111
- warn 'Current task updated'
112
+ warn("Current task updated")
112
113
  end
113
114
  end
114
115
  end
@@ -15,11 +15,11 @@ module Abt
15
15
  end
16
16
 
17
17
  def path
18
- Path.new(local_available? && git['path'] || '')
18
+ Path.new(local_available? && git["path"] || "")
19
19
  end
20
20
 
21
21
  def path=(new_path)
22
- git['path'] = new_path
22
+ git["path"] = new_path
23
23
  end
24
24
 
25
25
  def clear_local(verbose: true)
@@ -31,41 +31,41 @@ module Abt
31
31
  end
32
32
 
33
33
  def access_token
34
- return git_global['accessToken'] unless git_global['accessToken'].nil?
34
+ return git_global["accessToken"] unless git_global["accessToken"].nil?
35
35
 
36
- git_global['accessToken'] = cli.prompt.text([
37
- 'Please provide your personal access token for Harvest.',
38
- 'If you don\'t have one, create one here: https://id.getharvest.com/developers',
39
- '',
40
- 'Enter access token'
36
+ git_global["accessToken"] = cli.prompt.text([
37
+ "Please provide your personal access token for Harvest.",
38
+ "If you don't have one, create one here: https://id.getharvest.com/developers",
39
+ "",
40
+ "Enter access token"
41
41
  ].join("\n"))
42
42
  end
43
43
 
44
44
  def account_id
45
- return git_global['accountId'] unless git_global['accountId'].nil?
45
+ return git_global["accountId"] unless git_global["accountId"].nil?
46
46
 
47
- git_global['accountId'] = cli.prompt.text([
48
- 'Please provide harvest account id.',
49
- 'This information is shown next to your generated access token',
50
- '',
51
- 'Enter account id'
47
+ git_global["accountId"] = cli.prompt.text([
48
+ "Please provide harvest account id.",
49
+ "This information is shown next to your generated access token",
50
+ "",
51
+ "Enter account id"
52
52
  ].join("\n"))
53
53
  end
54
54
 
55
55
  def user_id
56
- return git_global['userId'] unless git_global['userId'].nil?
56
+ return git_global["userId"] unless git_global["userId"].nil?
57
57
 
58
- git_global['userId'] = api.get('users/me')['id'].to_s
58
+ git_global["userId"] = api.get("users/me")["id"].to_s
59
59
  end
60
60
 
61
61
  private
62
62
 
63
63
  def git
64
- @git ||= GitConfig.new('local', 'abt.harvest')
64
+ @git ||= GitConfig.new("local", "abt.harvest")
65
65
  end
66
66
 
67
67
  def git_global
68
- @git_global ||= GitConfig.new('global', 'abt.harvest')
68
+ @git_global ||= GitConfig.new("global", "abt.harvest")
69
69
  end
70
70
 
71
71
  def api
@@ -4,15 +4,15 @@ module Abt
4
4
  module Providers
5
5
  module Harvest
6
6
  class Path < String
7
- PATH_REGEX = %r{^(?<project_id>\d+)?(/(?<task_id>\d+))?$}.freeze
7
+ PATH_REGEX = %r{^(?<project_id>\d+)?/?(?<task_id>\d+)?$}.freeze
8
8
 
9
9
  def self.from_ids(project_id = nil, task_id = nil)
10
- path = project_id ? [project_id, *task_id].join('/') : ''
11
- new path
10
+ path = project_id ? [project_id, *task_id].join("/") : ""
11
+ new(path)
12
12
  end
13
13
 
14
- def initialize(path = '')
15
- raise Abt::Cli::Abort, "Invalid path: #{path}" unless path =~ PATH_REGEX
14
+ def initialize(path = "")
15
+ raise Abt::Cli::Abort, "Invalid path: #{path}" unless PATH_REGEX.match?(path)
16
16
 
17
17
  super
18
18
  end
data/lib/abt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abt
4
- VERSION = '0.0.21'
4
+ VERSION = "0.0.22"
5
5
  end
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.21
4
+ version: 0.0.22
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-03-10 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector
@@ -80,6 +80,7 @@ files:
80
80
  - "./lib/abt/base_command.rb"
81
81
  - "./lib/abt/cli.rb"
82
82
  - "./lib/abt/cli/arguments_parser.rb"
83
+ - "./lib/abt/cli/global_commands.rb"
83
84
  - "./lib/abt/cli/global_commands/commands.rb"
84
85
  - "./lib/abt/cli/global_commands/examples.rb"
85
86
  - "./lib/abt/cli/global_commands/help.rb"
@@ -122,7 +123,7 @@ files:
122
123
  - "./lib/abt/providers/devops/commands/init.rb"
123
124
  - "./lib/abt/providers/devops/commands/pick.rb"
124
125
  - "./lib/abt/providers/devops/commands/share.rb"
125
- - "./lib/abt/providers/devops/commands/work-items.rb"
126
+ - "./lib/abt/providers/devops/commands/work_items.rb"
126
127
  - "./lib/abt/providers/devops/configuration.rb"
127
128
  - "./lib/abt/providers/devops/path.rb"
128
129
  - "./lib/abt/providers/git.rb"
@@ -158,14 +159,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
160
  - - ">="
160
161
  - !ruby/object:Gem::Version
161
- version: '0'
162
+ version: 2.5.0
162
163
  required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  requirements:
164
165
  - - ">="
165
166
  - !ruby/object:Gem::Version
166
167
  version: '0'
167
168
  requirements: []
168
- rubygems_version: 3.0.3
169
+ rubygems_version: 3.1.4
169
170
  signing_key:
170
171
  specification_version: 4
171
172
  summary: Versatile scripts