abt-cli 0.0.2 → 0.0.3

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/bin/abt +3 -1
  3. data/lib/abt.rb +11 -0
  4. data/lib/abt/cli.rb +25 -29
  5. data/lib/abt/cli/dialogs.rb +2 -2
  6. data/lib/abt/cli/io.rb +21 -0
  7. data/lib/abt/{help.rb → docs.rb} +8 -14
  8. data/lib/abt/{help → docs}/cli.rb +3 -3
  9. data/lib/abt/{help → docs}/markdown.rb +3 -3
  10. data/lib/abt/helpers.rb +16 -0
  11. data/lib/abt/providers/asana.rb +9 -50
  12. data/lib/abt/providers/asana/api.rb +57 -0
  13. data/lib/abt/providers/asana/base_command.rb +5 -12
  14. data/lib/abt/providers/asana/commands/clear.rb +24 -0
  15. data/lib/abt/providers/asana/commands/clear_global.rb +24 -0
  16. data/lib/abt/providers/asana/commands/current.rb +71 -0
  17. data/lib/abt/providers/asana/commands/harvest_time_entry_data.rb +50 -0
  18. data/lib/abt/providers/asana/commands/init.rb +63 -0
  19. data/lib/abt/providers/asana/commands/move.rb +56 -0
  20. data/lib/abt/providers/asana/commands/pick_task.rb +48 -0
  21. data/lib/abt/providers/asana/commands/projects.rb +32 -0
  22. data/lib/abt/providers/asana/commands/start.rb +60 -0
  23. data/lib/abt/providers/asana/commands/tasks.rb +37 -0
  24. data/lib/abt/providers/asana/configuration.rb +105 -0
  25. data/lib/abt/providers/harvest.rb +9 -0
  26. data/lib/abt/version.rb +1 -1
  27. metadata +18 -15
  28. data/lib/abt/asana_client.rb +0 -53
  29. data/lib/abt/providers/asana/clear.rb +0 -24
  30. data/lib/abt/providers/asana/clear_global.rb +0 -24
  31. data/lib/abt/providers/asana/current.rb +0 -69
  32. data/lib/abt/providers/asana/harvest_link_entry_data.rb +0 -48
  33. data/lib/abt/providers/asana/init.rb +0 -62
  34. data/lib/abt/providers/asana/move.rb +0 -54
  35. data/lib/abt/providers/asana/pick_task.rb +0 -46
  36. data/lib/abt/providers/asana/projects.rb +0 -30
  37. data/lib/abt/providers/asana/start.rb +0 -22
  38. data/lib/abt/providers/asana/tasks.rb +0 -35
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Abt
4
- module Providers
5
- class Asana
6
- class Move < BaseCommand
7
- def self.command
8
- 'move asana[:<project-gid>/<task-gid>]'
9
- end
10
-
11
- def self.description
12
- 'Move current or specified task to another section (column)'
13
- end
14
-
15
- def call
16
- print_task(project, task)
17
-
18
- move_task
19
-
20
- warn "Asana task moved to #{section['name']}"
21
- rescue Abt::HttpError::HttpError => e
22
- warn e
23
- abort 'Unable to move asana task'
24
- end
25
-
26
- private
27
-
28
- def task
29
- @task ||= Asana.client.get("tasks/#{task_gid}")
30
- end
31
-
32
- def move_task
33
- body = { data: { task: task_gid } }
34
- body_json = Oj.dump(body, mode: :json)
35
- Asana.client.post("sections/#{section['gid']}/addTask", body_json)
36
- end
37
-
38
- def section
39
- @section ||= cli.prompt_choice 'Move asana task to?', sections
40
- end
41
-
42
- def project
43
- @project ||= Asana.client.get("projects/#{project_gid}")
44
- end
45
-
46
- def sections
47
- Asana.client.get_paged("projects/#{project_gid}/sections")
48
- rescue Abt::HttpError::HttpError
49
- []
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Abt
4
- module Providers
5
- class Asana
6
- class PickTask < BaseCommand
7
- def self.command
8
- 'pick-task asana[:<project-gid>]'
9
- end
10
-
11
- def self.description
12
- 'Pick task for current git repository'
13
- end
14
-
15
- def call
16
- warn project['name']
17
- task = cli.prompt_choice 'Select a task', tasks
18
-
19
- remember_project_gid(project_gid) # We might have gotten the project ID as an argument
20
- remember_task_gid(task['gid'])
21
-
22
- print_task(project, task)
23
- end
24
-
25
- private
26
-
27
- def project
28
- @project ||= Asana.client.get("projects/#{project_gid}")
29
- end
30
-
31
- def tasks
32
- @tasks ||= begin
33
- section = cli.prompt_choice 'Which section?', sections
34
- Asana.client.get_paged('tasks', section: section['gid'])
35
- end
36
- end
37
-
38
- def sections
39
- Asana.client.get_paged("projects/#{project_gid}/sections")
40
- rescue Abt::HttpError::HttpError
41
- []
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Abt
4
- module Providers
5
- class Asana
6
- class Projects < BaseCommand
7
- def self.command
8
- 'projects asana'
9
- end
10
-
11
- def self.description
12
- 'List all available projects - useful for piping into grep etc.'
13
- end
14
-
15
- def call
16
- projects.map do |project|
17
- print_project(project)
18
- end
19
- end
20
-
21
- private
22
-
23
- def projects
24
- @projects ||=
25
- Asana.client.get_paged('projects', workspace: Asana.workspace_gid, archived: false)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Abt
4
- module Providers
5
- class Asana
6
- class Start < BaseCommand
7
- def self.command
8
- 'start asana[:<project-gid>/<task-gid>]'
9
- end
10
-
11
- def self.description
12
- 'Set current task and move it to a section (column) of your choice'
13
- end
14
-
15
- def call
16
- Current.new(arg_str: arg_str, cli: cli).call unless arg_str.nil?
17
- Move.new(arg_str: arg_str, cli: cli).call
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Abt
4
- module Providers
5
- class Asana
6
- class Tasks < BaseCommand
7
- def self.command
8
- 'tasks asana'
9
- end
10
-
11
- def self.description
12
- 'List available tasks on project - useful for piping into grep etc.'
13
- end
14
-
15
- def call
16
- tasks.each do |task|
17
- print_task(project, task)
18
- end
19
- end
20
-
21
- private
22
-
23
- def project
24
- @project ||= begin
25
- Asana.client.get("projects/#{project_gid}")
26
- end
27
- end
28
-
29
- def tasks
30
- @tasks ||= Asana.client.get_paged('tasks', project: project['gid'])
31
- end
32
- end
33
- end
34
- end
35
- end