abt-cli 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3568d2d1acd067392e3832ee00bb1eb6f1fdcb6d9526fe1f747674c452173543
4
- data.tar.gz: f189b4c27d9cac1703211dc4c9fefdd33d359149d336d74f67f47aa9e9d96137
3
+ metadata.gz: 5044c8e5cb4330dd9db124834ee6f9bffca78a0ffaa08c268ba35eb3b0a21fe9
4
+ data.tar.gz: d9eb98460e021a032f9efdc0d9b2b98a20b57aba6267ef9024ee6f840bcf6858
5
5
  SHA512:
6
- metadata.gz: c38b239739f77fd58ce6df48e7f4057fb66a1a50f96bb2d7469ef7b0809b085d643face8fdbc82f9bb654ea75e565f60e9629952f9cc894abe9745101fd670bb
7
- data.tar.gz: f5fdf894aba1ca64f7a815f7aa1e17d2c23e3c690220f54b4cd0351586c293fd7a5716dbac544c9a63be6fb6ea8154e9e53c2e76658406e67f95656c597ab4f6
6
+ metadata.gz: e2536f6b91bebf10d0fe637864045f61d04f90aa1b1ede6bd0a0db62ad54ef54cb541eda71fca2554cd741fe0011cb5586a0bb904ec412a6a07d90fc6c477208
7
+ data.tar.gz: 10c5fcf70d15dcfff152cf62a3d39109db499768c5fbb96d0eadecc107c85150e9277f647da482ea72d6d2cab68974b950500c2e433a0a3f8c1547c6c6fe74a0
@@ -60,7 +60,7 @@ module Abt
60
60
  def args_from_stdin
61
61
  input = STDIN.read
62
62
 
63
- return [] if input.nil?
63
+ abort 'No input from pipe' if input.nil? || input.empty?
64
64
 
65
65
  # Exclude comment part of piped input lines
66
66
  lines_without_comments = input.lines.map do |line|
@@ -25,13 +25,15 @@ module Abt
25
25
  end
26
26
 
27
27
  def prompt_choice(text, options, allow_back_option = false)
28
- if options.one?
29
- warn "Selected: #{options.first['name']}"
30
- return options.first
31
- end
32
-
33
28
  warn "#{text}:"
34
29
 
30
+ if options.length.zero?
31
+ abort 'No available options' unless allow_back_option
32
+
33
+ warn 'No available options'
34
+ return nil
35
+ end
36
+
35
37
  print_options(options)
36
38
  select_options(options, allow_back_option)
37
39
  end
@@ -45,11 +47,12 @@ module Abt
45
47
  end
46
48
 
47
49
  def select_options(options, allow_back_option)
48
- while (number = read_option_number(options.length, allow_back_option))
50
+ loop do
51
+ number = read_option_number(options.length, allow_back_option)
49
52
  if number.nil?
50
53
  return nil if allow_back_option
51
54
 
52
- abort
55
+ next
53
56
  end
54
57
 
55
58
  option = options[number - 1]
@@ -18,7 +18,7 @@ module Abt
18
18
 
19
19
  cli.warn project['name']
20
20
 
21
- task = cli.prompt_choice 'Select a task', tasks
21
+ task = select_task
22
22
 
23
23
  config.project_gid = project_gid # We might have gotten the project ID as an argument
24
24
  config.task_gid = task['gid']
@@ -32,14 +32,26 @@ module Abt
32
32
  @project ||= api.get("projects/#{project_gid}")
33
33
  end
34
34
 
35
- def tasks
36
- @tasks ||= begin
35
+ def select_task
36
+ loop do
37
37
  section = cli.prompt_choice 'Which section?', sections
38
38
  cli.warn 'Fetching tasks...'
39
- api.get_paged('tasks', section: section['gid'], opt_fields: 'name,permalink_url')
39
+ tasks = tasks_in_section(section)
40
+
41
+ if tasks.length.zero?
42
+ cli.warn 'Section is empty'
43
+ next
44
+ end
45
+
46
+ task = cli.prompt_choice 'Select a task', tasks, true
47
+ return task if task
40
48
  end
41
49
  end
42
50
 
51
+ def tasks_in_section(section)
52
+ api.get_paged('tasks', section: section['gid'], opt_fields: 'name,permalink_url')
53
+ end
54
+
43
55
  def sections
44
56
  @sections ||= begin
45
57
  cli.warn 'Fetching sections...'
@@ -109,9 +109,13 @@ module Abt
109
109
  workspaces = api.get_paged('workspaces')
110
110
  if workspaces.empty?
111
111
  cli.abort 'Your asana access token does not have access to any workspaces'
112
+ elsif workspaces.one?
113
+ workspace = workspaces.first
114
+ cli.warn "Selected Asana workspace #{workspace['name']}"
115
+ else
116
+ workspace = cli.prompt_choice('Select Asana workspace', workspaces)
112
117
  end
113
118
 
114
- workspace = cli.prompt_choice('Select Asana workspace', workspaces)
115
119
  git.global['workspaceGid'] = workspace['gid']
116
120
  workspace
117
121
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abt
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
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.8
4
+ version: 0.0.9
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-20 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector