abt-cli 0.0.9 → 0.0.14

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bin/abt +0 -6
  3. data/lib/abt.rb +8 -0
  4. data/lib/abt/cli.rb +5 -5
  5. data/lib/abt/cli/dialogs.rb +28 -9
  6. data/lib/abt/git_config.rb +28 -11
  7. data/lib/abt/helpers.rb +1 -1
  8. data/lib/abt/providers/asana/base_command.rb +11 -0
  9. data/lib/abt/providers/asana/commands/add.rb +75 -0
  10. data/lib/abt/providers/asana/commands/branch-name.rb +44 -0
  11. data/lib/abt/providers/asana/commands/current.rb +3 -3
  12. data/lib/abt/providers/asana/commands/finalize.rb +1 -1
  13. data/lib/abt/providers/asana/commands/harvest_time_entry_data.rb +3 -4
  14. data/lib/abt/providers/asana/commands/init.rb +5 -0
  15. data/lib/abt/providers/asana/commands/pick.rb +1 -0
  16. data/lib/abt/providers/asana/commands/share.rb +3 -3
  17. data/lib/abt/providers/asana/commands/start.rb +1 -1
  18. data/lib/abt/providers/asana/commands/tasks.rb +2 -0
  19. data/lib/abt/providers/asana/configuration.rb +4 -2
  20. data/lib/abt/providers/devops.rb +19 -0
  21. data/lib/abt/providers/devops/api.rb +95 -0
  22. data/lib/abt/providers/devops/base_command.rb +98 -0
  23. data/lib/abt/providers/devops/commands/boards.rb +34 -0
  24. data/lib/abt/providers/devops/commands/branch-name.rb +45 -0
  25. data/lib/abt/providers/devops/commands/clear.rb +24 -0
  26. data/lib/abt/providers/devops/commands/clear_global.rb +24 -0
  27. data/lib/abt/providers/devops/commands/current.rb +93 -0
  28. data/lib/abt/providers/devops/commands/harvest_time_entry_data.rb +53 -0
  29. data/lib/abt/providers/devops/commands/init.rb +72 -0
  30. data/lib/abt/providers/devops/commands/pick.rb +78 -0
  31. data/lib/abt/providers/devops/commands/share.rb +26 -0
  32. data/lib/abt/providers/devops/commands/work-items.rb +46 -0
  33. data/lib/abt/providers/devops/configuration.rb +110 -0
  34. data/lib/abt/providers/git.rb +19 -0
  35. data/lib/abt/providers/git/commands/branch.rb +80 -0
  36. data/lib/abt/providers/harvest/base_command.rb +11 -0
  37. data/lib/abt/providers/harvest/commands/current.rb +3 -3
  38. data/lib/abt/providers/harvest/commands/pick.rb +1 -0
  39. data/lib/abt/providers/harvest/commands/start.rb +10 -11
  40. data/lib/abt/providers/harvest/commands/tasks.rb +2 -0
  41. data/lib/abt/providers/harvest/commands/track.rb +6 -4
  42. data/lib/abt/providers/harvest/configuration.rb +4 -3
  43. data/lib/abt/version.rb +1 -1
  44. metadata +20 -2
@@ -20,6 +20,17 @@ module Abt
20
20
 
21
21
  private
22
22
 
23
+ def require_project!
24
+ cli.abort 'No current/specified project. Did you initialize Harvest?' if project_id.nil?
25
+ end
26
+
27
+ def require_task!
28
+ if project_id.nil?
29
+ cli.abort 'No current/specified project. Did you initialize Harvest and pick a task?'
30
+ end
31
+ cli.abort 'No current/specified task. Did you pick a Harvest task?' if task_id.nil?
32
+ end
33
+
23
34
  def same_args_as_config?
24
35
  project_id == config.project_id && task_id == config.task_id
25
36
  end
@@ -14,6 +14,8 @@ module Abt
14
14
  end
15
15
 
16
16
  def call
17
+ require_project!
18
+
17
19
  if same_args_as_config? || !config.local_available?
18
20
  show_current_configuration
19
21
  else
@@ -25,9 +27,7 @@ module Abt
25
27
  private
26
28
 
27
29
  def show_current_configuration
28
- if project_id.nil?
29
- cli.warn 'No project selected'
30
- elsif task_id.nil?
30
+ if task_id.nil?
31
31
  print_project(project)
32
32
  else
33
33
  print_task(project, task)
@@ -15,6 +15,7 @@ module Abt
15
15
 
16
16
  def call
17
17
  cli.abort 'Must be run inside a git repository' unless config.local_available?
18
+ require_project!
18
19
 
19
20
  cli.warn project['name']
20
21
  task = cli.prompt_choice 'Select a task', tasks
@@ -14,10 +14,10 @@ module Abt
14
14
  end
15
15
 
16
16
  def call
17
- start_output = call_start
18
- puts start_output
17
+ track_output = call_track
18
+ puts track_output
19
19
 
20
- use_arg_str(arg_str_from_start_output(start_output))
20
+ use_arg_str(arg_str_from_track_output(track_output))
21
21
 
22
22
  maybe_override_current_task
23
23
  rescue Abt::HttpError::HttpError => e
@@ -27,18 +27,17 @@ module Abt
27
27
 
28
28
  private
29
29
 
30
- def arg_str_from_start_output(output)
30
+ def arg_str_from_track_output(output)
31
31
  output = output.split(' # ').first
32
32
  output.split(':')[1]
33
33
  end
34
34
 
35
- def call_start
35
+ def call_track
36
+ input = StringIO.new(cli.args.join(' '))
36
37
  output = StringIO.new
37
- Abt::Cli.new(argv: ['track', *cli.args], output: output).perform
38
+ Abt::Cli.new(argv: ['track'], output: output, input: input).perform
38
39
 
39
- output_str = output.string.strip
40
- cli.abort 'No task provided' if output_str.empty?
41
- output_str
40
+ output.string.strip
42
41
  end
43
42
 
44
43
  def maybe_override_current_task
@@ -47,9 +46,9 @@ module Abt
47
46
  return unless config.local_available?
48
47
  return unless cli.prompt_boolean 'Set selected task as current?'
49
48
 
49
+ input = StringIO.new("harvest:#{project_id}/#{task_id}")
50
50
  output = StringIO.new
51
- Abt::Cli.new(argv: ['current', "harvest:#{project_id}/#{task_id}"],
52
- output: output).perform
51
+ Abt::Cli.new(argv: ['current'], output: output, input: input).perform
53
52
  end
54
53
  end
55
54
  end
@@ -14,6 +14,8 @@ module Abt
14
14
  end
15
15
 
16
16
  def call
17
+ require_project!
18
+
17
19
  tasks.each do |task|
18
20
  print_task(project, task)
19
21
  end
@@ -14,8 +14,7 @@ module Abt
14
14
  end
15
15
 
16
16
  def call
17
- abort 'No current/provided task' if task_id.nil?
18
- cli.abort('No task selected') if task_id.nil?
17
+ require_task!
19
18
 
20
19
  print_task(created_time_entry['project'], created_time_entry['task'])
21
20
 
@@ -50,8 +49,11 @@ module Abt
50
49
 
51
50
  def external_link_data
52
51
  @external_link_data ||= begin
53
- arg_strs = cli.args.join(' ')
54
- lines = `#{$PROGRAM_NAME} harvest-time-entry-data #{arg_strs}`.split("\n")
52
+ input = StringIO.new(cli.args.join(' '))
53
+ output = StringIO.new
54
+ Abt::Cli.new(argv: ['harvest-time-entry-data'], output: output, input: input).perform
55
+
56
+ lines = output.string.strip.lines
55
57
 
56
58
  return if lines.empty?
57
59
 
@@ -44,9 +44,10 @@ module Abt
44
44
  end
45
45
 
46
46
  def clear_global
47
- git.global['userId'] = nil
48
- git.global['accountId'] = nil
49
- git.global['accessToken'] = nil
47
+ git.global.keys.each do |key|
48
+ cli.puts 'Deleting configuration: ' + key
49
+ git.global[key] = nil
50
+ end
50
51
  end
51
52
 
52
53
  def access_token
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.9'
4
+ VERSION = '0.0.14'
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.9
4
+ version: 0.0.14
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-27 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector
@@ -88,6 +88,8 @@ files:
88
88
  - "./lib/abt/providers/asana.rb"
89
89
  - "./lib/abt/providers/asana/api.rb"
90
90
  - "./lib/abt/providers/asana/base_command.rb"
91
+ - "./lib/abt/providers/asana/commands/add.rb"
92
+ - "./lib/abt/providers/asana/commands/branch-name.rb"
91
93
  - "./lib/abt/providers/asana/commands/clear.rb"
92
94
  - "./lib/abt/providers/asana/commands/clear_global.rb"
93
95
  - "./lib/abt/providers/asana/commands/current.rb"
@@ -100,6 +102,22 @@ files:
100
102
  - "./lib/abt/providers/asana/commands/start.rb"
101
103
  - "./lib/abt/providers/asana/commands/tasks.rb"
102
104
  - "./lib/abt/providers/asana/configuration.rb"
105
+ - "./lib/abt/providers/devops.rb"
106
+ - "./lib/abt/providers/devops/api.rb"
107
+ - "./lib/abt/providers/devops/base_command.rb"
108
+ - "./lib/abt/providers/devops/commands/boards.rb"
109
+ - "./lib/abt/providers/devops/commands/branch-name.rb"
110
+ - "./lib/abt/providers/devops/commands/clear.rb"
111
+ - "./lib/abt/providers/devops/commands/clear_global.rb"
112
+ - "./lib/abt/providers/devops/commands/current.rb"
113
+ - "./lib/abt/providers/devops/commands/harvest_time_entry_data.rb"
114
+ - "./lib/abt/providers/devops/commands/init.rb"
115
+ - "./lib/abt/providers/devops/commands/pick.rb"
116
+ - "./lib/abt/providers/devops/commands/share.rb"
117
+ - "./lib/abt/providers/devops/commands/work-items.rb"
118
+ - "./lib/abt/providers/devops/configuration.rb"
119
+ - "./lib/abt/providers/git.rb"
120
+ - "./lib/abt/providers/git/commands/branch.rb"
103
121
  - "./lib/abt/providers/harvest.rb"
104
122
  - "./lib/abt/providers/harvest/api.rb"
105
123
  - "./lib/abt/providers/harvest/base_command.rb"