abt-cli 0.0.17 → 0.0.18

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: 90cf28ee322298a2c1f7c99cf91ea0f820dd1fc0636a13d6dfe4c1f3db8e9ba1
4
- data.tar.gz: 4d63e302def09512a225593952bd29e2de2ffde5387a4f3af4da59a7ec8ecadf
3
+ metadata.gz: df400d04c979d979ab2ead353d68374b8266c0fff678103991cc6443512b703b
4
+ data.tar.gz: 0345141c38eae6904d11f40a3045fccd048d8009b70fe9714f5e0986f1779861
5
5
  SHA512:
6
- metadata.gz: b11c12bcc780bb2725b7c088f8ecf8fb2e47af767b9d906c042020bb999d427ef97a5fb8fc0151038590fe25ae0ba2aa69d4ec7e42758df1d03fbdf0c276870c
7
- data.tar.gz: 62a3d10d11a58c879c31173ae393af393f0c841b9c99589a54d84b29177869686251d37ea6babf114dc7280a4a5a620fe13dbe3efbc5f324037b2556358d9737
6
+ metadata.gz: 1979110cbd58f0bc71b83ad7211b86e17c5b078e842d4f99ca839c88a88d627ab92506736cd83b6e414cbea2ec2a82592f6e8b3f1effdbd2b57df7decd63793e
7
+ data.tar.gz: 6af0e9bb436b304cda9d3acf6c86733050c9a7acffb691017d968e89e3f4e8e51b9fa4cdf5e3a85373ff2f684fa61e41afce0c1b9011d2e6b5551935b40530ea
data/lib/abt/cli.rb CHANGED
@@ -9,7 +9,7 @@ module Abt
9
9
  class Abort < StandardError; end
10
10
  class Exit < StandardError; end
11
11
 
12
- attr_reader :command, :scheme_arguments, :input, :output, :err_output, :prompt
12
+ attr_reader :command, :aris, :input, :output, :err_output, :prompt
13
13
 
14
14
  def initialize(argv: ARGV, input: STDIN, output: STDOUT, err_output: STDERR)
15
15
  (@command, *remaining_args) = argv
@@ -18,18 +18,18 @@ module Abt
18
18
  @err_output = err_output
19
19
  @prompt = Abt::Cli::Prompt.new(output: err_output)
20
20
 
21
- @scheme_arguments = ArgumentsParser.new(sanitized_piped_args + remaining_args).parse
21
+ @aris = ArgumentsParser.new(sanitized_piped_args + remaining_args).parse
22
22
  end
23
23
 
24
24
  def perform
25
25
  return if handle_global_commands!
26
26
 
27
- abort('No scheme arguments') if scheme_arguments.empty?
27
+ abort('No ARIs') if aris.empty?
28
28
 
29
- process_scheme_arguments
29
+ process_aris
30
30
  end
31
31
 
32
- def print_scheme_argument(scheme, path, description = nil)
32
+ def print_ari(scheme, path, description = nil)
33
33
  command = "#{scheme}:#{path}"
34
34
  command += " # #{description}" unless description.nil?
35
35
  output.puts command
@@ -96,30 +96,30 @@ module Abt
96
96
  line.split(' # ').first
97
97
  end
98
98
 
99
- # Allow multiple scheme arguments on a single piped input line
100
- # TODO: Force the user to pick a single scheme argument
99
+ # Allow multiple ARIs on a single piped input line
100
+ # TODO: Force the user to pick a single ARI
101
101
  joined_lines = lines_without_comments.join(' ').strip
102
102
  joined_lines.split(/\s+/)
103
103
  end
104
104
  end
105
105
 
106
- def process_scheme_arguments
106
+ def process_aris
107
107
  used_schemes = []
108
- scheme_arguments.each do |scheme_argument|
109
- scheme = scheme_argument.scheme
110
- path = scheme_argument.path
108
+ aris.each do |ari|
109
+ scheme = ari.scheme
110
+ path = ari.path
111
111
 
112
112
  if used_schemes.include?(scheme)
113
- warn "Dropping command for already used scheme: #{scheme_argument}"
113
+ warn "Dropping command for already used scheme: #{ari}"
114
114
  next
115
115
  end
116
116
 
117
117
  command_class = get_command_class(scheme)
118
118
  next if command_class.nil?
119
119
 
120
- print_command(command, scheme_argument) if output.isatty
120
+ print_command(command, ari) if output.isatty
121
121
  begin
122
- command_class.new(path: path, cli: self, flags: scheme_argument.flags).perform
122
+ command_class.new(path: path, cli: self, flags: ari.flags).perform
123
123
  rescue Exit => e
124
124
  puts e.message
125
125
  end
@@ -129,7 +129,7 @@ module Abt
129
129
 
130
130
  return unless used_schemes.empty? && output.isatty
131
131
 
132
- abort 'No providers found for command and scheme argument(s)'
132
+ abort 'No providers found for command and ARI(s)'
133
133
  end
134
134
 
135
135
  def get_command_class(scheme)
@@ -139,8 +139,8 @@ module Abt
139
139
  provider.command_class(command)
140
140
  end
141
141
 
142
- def print_command(name, scheme_argument)
143
- warn "===== #{name} #{scheme_argument} =====".upcase
142
+ def print_command(name, ari)
143
+ warn "===== #{name} #{ari} =====".upcase
144
144
  end
145
145
  end
146
146
  end
@@ -3,7 +3,7 @@
3
3
  module Abt
4
4
  class Cli
5
5
  class ArgumentsParser
6
- class SchemeArgument
6
+ class Ari
7
7
  attr_reader :scheme, :path, :flags
8
8
 
9
9
  def initialize(scheme:, path:, flags:)
@@ -19,7 +19,7 @@ module Abt
19
19
  [str, *flags].join(' ')
20
20
  end
21
21
  end
22
- class SchemeArguments < Array
22
+ class Aris < Array
23
23
  def to_s
24
24
  map(&:to_s).join(' -- ')
25
25
  end
@@ -32,14 +32,14 @@ module Abt
32
32
  end
33
33
 
34
34
  def parse
35
- result = SchemeArguments.new
35
+ result = Aris.new
36
36
  rest = arguments.dup
37
37
 
38
38
  until rest.empty?
39
39
  (scheme, path) = rest.shift.split(':')
40
40
  flags = take_flags(rest)
41
41
 
42
- result << SchemeArgument.new(scheme: scheme, path: path, flags: flags)
42
+ result << Ari.new(scheme: scheme, path: path, flags: flags)
43
43
  end
44
44
 
45
45
  result
data/lib/abt/docs.rb CHANGED
@@ -10,11 +10,11 @@ module Abt
10
10
  def basic_examples
11
11
  {
12
12
  'Getting started:' => {
13
- 'abt init asana harvest' => 'Setup asana and harvest project git repo in working dir',
14
- 'abt pick harvest' => 'Pick harvest tasks, for most projects this will stay the same',
15
- 'abt pick asana | abt start harvest' => 'Pick asana task and start working',
13
+ 'abt init asana harvest' => 'Setup asana and harvest project for local git repo',
14
+ 'abt pick harvest' => 'Pick harvest task. This will likely stay the same throughout the project',
15
+ 'abt pick asana | abt start harvest' => 'Pick asana task and start tracking time',
16
16
  'abt stop harvest' => 'Stop time tracker',
17
- 'abt start asana harvest' => 'Continue working, e.g. after a break',
17
+ 'abt start asana harvest' => 'Continue working, e.g., after a break',
18
18
  'abt finalize asana' => 'Finalize the selected asana task'
19
19
  }
20
20
  }
@@ -22,11 +22,11 @@ module Abt
22
22
 
23
23
  def extended_examples
24
24
  {
25
- 'Tracking meetings (without changing the config):' => {
25
+ 'Tracking meetings (without switching current task setting):' => {
26
26
  'abt pick asana -d | abt track harvest' => 'Track on asana meeting task',
27
27
  'abt pick harvest -d | abt track harvest -c "Name of meeting"' => 'Track on separate harvest-task'
28
28
  },
29
- 'Command output can be piped, e.g.:' => {
29
+ 'Command output can be piped:' => {
30
30
  'abt tasks asana | grep -i <name of task>' => nil,
31
31
  'abt tasks asana | grep -i <name of task> | abt start' => nil
32
32
  },
@@ -36,9 +36,9 @@ module Abt
36
36
  'abt start <shared configuration>' => 'Start a shared configuration'
37
37
  },
38
38
  'Flags:' => {
39
- 'abt start harvest -c "comment"' => 'Add command flags after <scheme>:<path>',
40
- 'abt start harvest -c "comment" -- asana' => 'Use -- to mark the end of a flag list if it\'s to be followed by a <scheme-argument>',
41
- 'abt pick harvest | abt start -c "comment"' => 'Flags placed directly after a command applies to piped in <scheme-argument>'
39
+ 'abt start harvest -c "comment"' => 'Add command flags after ARIs',
40
+ 'abt start harvest -c "comment" -- asana' => 'Use -- to end a list of flags, so that it can be followed by another ARI',
41
+ 'abt pick harvest | abt start -c "comment"' => 'Flags placed directly after a command applies to the piped in ARI'
42
42
  }
43
43
  }
44
44
  end
data/lib/abt/docs/cli.rb CHANGED
@@ -8,10 +8,10 @@ module Abt
8
8
  <<~TXT
9
9
  Usage: #{usage_line}
10
10
 
11
- <command> Name of command to execute, e.g. start, finalize etc.
12
- <scheme-argument> A URI-like identifier; scheme:path
13
- Points to a project/task etc. within a system.
14
- <options> Optional flags for the command and scheme argument
11
+ <command> Name of command to execute, e.g. start, finalize etc.
12
+ <ARI> A URI-like resource identifier with a scheme and an optional path
13
+ in the format: <scheme>[:<path>]. E.g., harvest:11111111/22222222
14
+ <options> Optional flags for the command and ARI
15
15
 
16
16
  #{formatted_examples(Docs.basic_examples)}
17
17
 
@@ -45,7 +45,7 @@ module Abt
45
45
  private
46
46
 
47
47
  def usage_line
48
- 'abt <command> [<scheme-argument>] [<options> --] [<scheme-argument>] ...'
48
+ 'abt <command> [<ARI>] [<options> --] [<ARI>] ...'
49
49
  end
50
50
 
51
51
  def formatted_examples(example_groups)
@@ -15,27 +15,28 @@ module Abt
15
15
 
16
16
  ## How does abt work?
17
17
 
18
- Abt uses a hybrid approach between having small scripts each doing one thing:
18
+ Abt is a hybrid af having small scripts each doing one thing:
19
19
  - `start-asana --project-gid xxxx --task-gid yyyy`
20
20
  - `start-harvest --project-id aaaa --task-id bbbb`
21
21
 
22
- And having a single highly advanced script that does everything:
22
+ And having a single highly advanced script that does everything with a single command:
23
23
  - `start xxxx/yyyy aaaa/bbbb`
24
24
 
25
- Abt looks like one script, but works like a bunch of light independent scripts:
25
+ Abt looks like one command, but works like a bunch of light scripts:
26
26
  - `abt start asana:xxxx/yyyy harvest:aaaa/bbbb`
27
27
 
28
28
  ## Usage
29
- `abt <command> [<scheme-argument>] [<options> --] [<scheme-argument>] ...`
29
+ `abt <command> [<ARI>] [<options> --] [<ARI>] ...`
30
30
 
31
31
  Definitions:
32
32
  - `<command>`: Name of command to execute, e.g. `start`, `finalize` etc.
33
- - `<scheme-argument>`: A URI-like identifier, `scheme:path`, pointing to a project/task etc. within a system.
34
- - `<options>`: Optional flags for the command and scheme argument
33
+ - `<ARI>`: A URI-like resource identifier with a scheme and an optional path in the format: `<scheme>[:<path>]`. E.g., `harvest:11111111/22222222`
34
+ - `<options>`: Optional flags for the command and ARI
35
35
 
36
36
  #{example_commands}
37
37
 
38
- ## Available commands:
38
+ ## Commands:
39
+
39
40
  Some commands have `[options]`. Run such a command with `--help` flag to view supported flags, e.g: `abt track harvest -h`
40
41
 
41
42
  #{provider_commands}
@@ -36,13 +36,13 @@ module Abt
36
36
  end
37
37
 
38
38
  def print_project(project)
39
- cli.print_scheme_argument('asana', project['gid'], project['name'])
39
+ cli.print_ari('asana', project['gid'], project['name'])
40
40
  cli.warn project['permalink_url'] if project.key?('permalink_url') && cli.output.isatty
41
41
  end
42
42
 
43
43
  def print_task(project, task)
44
44
  project = { 'gid' => project } if project.is_a?(String)
45
- cli.print_scheme_argument('asana', "#{project['gid']}/#{task['gid']}", task['name'])
45
+ cli.print_ari('asana', "#{project['gid']}/#{task['gid']}", task['name'])
46
46
  cli.warn task['permalink_url'] if task.key?('permalink_url') && cli.output.isatty
47
47
  end
48
48
 
@@ -31,7 +31,7 @@ module Abt
31
31
 
32
32
  return if flags[:"dry-run"]
33
33
 
34
- config.project_gid = project_gid # We might have gotten the project ID as an argument
34
+ config.project_gid = project_gid # We might have gotten the project ID from a path
35
35
  config.task_gid = task['gid']
36
36
  end
37
37
 
@@ -17,9 +17,9 @@ module Abt
17
17
  require_project!
18
18
 
19
19
  if task_gid.nil?
20
- cli.print_scheme_argument('asana', project_gid)
20
+ cli.print_ari('asana', project_gid)
21
21
  else
22
- cli.print_scheme_argument('asana', "#{project_gid}/#{task_gid}")
22
+ cli.print_ari('asana', "#{project_gid}/#{task_gid}")
23
23
  end
24
24
  end
25
25
  end
@@ -56,14 +56,14 @@ module Abt
56
56
  def print_board(organization_name, project_name, board)
57
57
  path = "#{organization_name}/#{project_name}/#{board['id']}"
58
58
 
59
- cli.print_scheme_argument('devops', path, board['name'])
59
+ cli.print_ari('devops', path, board['name'])
60
60
  # cli.warn board['url'] if board.key?('url') && cli.output.isatty # TODO: Web URL
61
61
  end
62
62
 
63
63
  def print_work_item(organization, project, board, work_item)
64
64
  path = "#{organization}/#{project}/#{board['id']}/#{work_item['id']}"
65
65
 
66
- cli.print_scheme_argument('devops', path, work_item['name'])
66
+ cli.print_ari('devops', path, work_item['name'])
67
67
  cli.warn work_item['url'] if work_item.key?('url') && cli.output.isatty
68
68
  end
69
69
 
@@ -17,7 +17,7 @@ module Abt
17
17
  require_work_item!
18
18
 
19
19
  args = [organization_name, project_name, board_id, work_item_id].compact
20
- cli.print_scheme_argument('devops', args.join('/'))
20
+ cli.print_ari('devops', args.join('/'))
21
21
  end
22
22
  end
23
23
  end
@@ -39,29 +39,29 @@ module Abt
39
39
 
40
40
  def branch_name # rubocop:disable Metrics/MethodLength
41
41
  @branch_name ||= begin
42
- if branch_names_from_scheme_arguments.empty?
42
+ if branch_names_from_aris.empty?
43
43
  cli.abort [
44
- 'None of the specified scheme arguments responded to `branch-name`.',
44
+ 'None of the specified ARIs responded to `branch-name`.',
45
45
  'Did you add compatible scheme? e.g.:',
46
46
  ' abt branch git asana',
47
47
  ' abt branch git devops'
48
48
  ].join("\n")
49
49
  end
50
50
 
51
- if branch_names_from_scheme_arguments.length > 1
51
+ if branch_names_from_aris.length > 1
52
52
  cli.abort [
53
- 'Got branch names from multiple scheme arguments, only one is supported',
53
+ 'Got branch names from multiple ARIs, only one is supported',
54
54
  'Branch names were:',
55
- *branch_names_from_scheme_arguments.map { |name| " #{name}" }
55
+ *branch_names_from_aris.map { |name| " #{name}" }
56
56
  ].join("\n")
57
57
  end
58
58
 
59
- branch_names_from_scheme_arguments.first
59
+ branch_names_from_aris.first
60
60
  end
61
61
  end
62
62
 
63
- def branch_names_from_scheme_arguments
64
- input = StringIO.new(cli.scheme_arguments.to_s)
63
+ def branch_names_from_aris
64
+ input = StringIO.new(cli.aris.to_s)
65
65
  output = StringIO.new
66
66
  Abt::Cli.new(argv: ['branch-name'], output: output, input: input).perform
67
67
 
@@ -36,7 +36,7 @@ module Abt
36
36
  end
37
37
 
38
38
  def print_project(project)
39
- cli.print_scheme_argument(
39
+ cli.print_ari(
40
40
  'harvest',
41
41
  project['id'],
42
42
  "#{project['client']['name']} > #{project['name']}"
@@ -44,7 +44,7 @@ module Abt
44
44
  end
45
45
 
46
46
  def print_task(project, task)
47
- cli.print_scheme_argument(
47
+ cli.print_ari(
48
48
  'harvest',
49
49
  "#{project['id']}/#{task['id']}",
50
50
  "#{project['name']} > #{task['name']}"
@@ -30,7 +30,7 @@ module Abt
30
30
 
31
31
  return if flags[:"dry-run"]
32
32
 
33
- config.project_id = project_id # We might have gotten the project ID as an argument
33
+ config.project_id = project_id # We might have gotten the project ID as a path
34
34
  config.task_id = task['id']
35
35
  end
36
36
 
@@ -17,9 +17,9 @@ module Abt
17
17
  if project_id.nil?
18
18
  cli.warn 'No project selected'
19
19
  elsif task_id.nil?
20
- cli.print_scheme_argument('harvest', project_id)
20
+ cli.print_ari('harvest', project_id)
21
21
  else
22
- cli.print_scheme_argument('harvest', "#{project_id}/#{task_id}")
22
+ cli.print_ari('harvest', "#{project_id}/#{task_id}")
23
23
  end
24
24
  end
25
25
  end
@@ -12,7 +12,7 @@ module Abt
12
12
  end
13
13
 
14
14
  def self.description
15
- 'Alias for: `abt track harvest`. Meant to used in combination with other scheme arguments, e.g. `abt start harvest asana`'
15
+ 'Alias for: `abt track harvest`. Meant to used in combination with other ARIs, e.g. `abt start harvest asana`'
16
16
  end
17
17
  end
18
18
  end
@@ -10,7 +10,7 @@ module Abt
10
10
  end
11
11
 
12
12
  def self.description
13
- 'Start tracker for current or specified task. Add a relevant scheme argument to link the time entry, e.g. `abt track harvest asana`'
13
+ 'Start tracker for current or specified task. Add a relevant ARI to link the time entry, e.g. `abt track harvest asana`'
14
14
  end
15
15
 
16
16
  def self.flags
@@ -77,7 +77,7 @@ module Abt
77
77
 
78
78
  def external_link_data
79
79
  @external_link_data ||= begin
80
- input = StringIO.new(cli.scheme_arguments.to_s)
80
+ input = StringIO.new(cli.aris.to_s)
81
81
  output = StringIO.new
82
82
  Abt::Cli.new(argv: ['harvest-time-entry-data'], output: output, input: input).perform
83
83
 
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.17'
4
+ VERSION = '0.0.18'
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.17
4
+ version: 0.0.18
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 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector