abt-cli 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/abt/ari.rb +1 -1
- data/lib/abt/base_command.rb +1 -1
- data/lib/abt/cli.rb +43 -28
- data/lib/abt/cli/arguments_parser.rb +7 -0
- data/lib/abt/cli/global_commands/commands.rb +23 -0
- data/lib/abt/cli/global_commands/examples.rb +23 -0
- data/lib/abt/cli/global_commands/help.rb +23 -0
- data/lib/abt/cli/global_commands/readme.rb +23 -0
- data/lib/abt/cli/global_commands/share.rb +36 -0
- data/lib/abt/cli/global_commands/version.rb +23 -0
- data/lib/abt/docs.rb +18 -2
- data/lib/abt/providers/asana/commands/share.rb +5 -3
- data/lib/abt/providers/devops/commands/share.rb +5 -3
- data/lib/abt/providers/harvest/commands/share.rb +5 -3
- data/lib/abt/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce59010855d53bf8b8731a680d7adcd21cef4eb93d421174aee893f27350cb1e
|
4
|
+
data.tar.gz: 8ac30f3ada5fcc7c75f7a9a91110340d579fd79d8c6226dd4f92a24bdf070d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cdbbd886589a06d20281e67a8376b3292cd61e432b7b672c968e2c5730a65707cc60d31d179acdcd7ad2a5eab9ebffe15866e08f5001b1922f291007146038b
|
7
|
+
data.tar.gz: d0e568a9db4e57207f1cd8d72c789fea3c456f282c6cc1b4a46694767317a0b5c4055d90d53903779c20cd7ecf3c5a0803b07ebafb03b9e07d5ed99f3be14a88
|
data/lib/abt/ari.rb
CHANGED
data/lib/abt/base_command.rb
CHANGED
data/lib/abt/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
Dir.glob("#{File.expand_path(__dir__)}/cli
|
3
|
+
Dir.glob("#{File.expand_path(__dir__)}/cli/**/*.rb").sort.each do |file|
|
4
4
|
require file
|
5
5
|
end
|
6
6
|
|
@@ -9,6 +9,20 @@ module Abt
|
|
9
9
|
class Abort < StandardError; end
|
10
10
|
class Exit < StandardError; end
|
11
11
|
|
12
|
+
def self.global_command_names
|
13
|
+
GlobalCommands.constants.sort.map { |constant_name| Helpers.const_to_command(constant_name) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.global_command_class(name)
|
17
|
+
name = 'help' if [nil, '-h', '--help'].include?(name)
|
18
|
+
name = 'version' if ['-v', '--version'].include?(name)
|
19
|
+
|
20
|
+
const_name = Helpers.command_to_const(name)
|
21
|
+
return unless GlobalCommands.const_defined?(const_name)
|
22
|
+
|
23
|
+
GlobalCommands.const_get(const_name)
|
24
|
+
end
|
25
|
+
|
12
26
|
attr_reader :command, :aris, :input, :output, :err_output, :prompt
|
13
27
|
|
14
28
|
def initialize(argv: ARGV, input: STDIN, output: STDOUT, err_output: STDERR)
|
@@ -21,11 +35,16 @@ module Abt
|
|
21
35
|
end
|
22
36
|
|
23
37
|
def perform
|
24
|
-
|
25
|
-
|
26
|
-
|
38
|
+
if command.nil?
|
39
|
+
warn("No command specified, printing help\n\n")
|
40
|
+
@command = 'help'
|
41
|
+
end
|
27
42
|
|
28
|
-
|
43
|
+
if global_command?
|
44
|
+
process_global_command
|
45
|
+
else
|
46
|
+
process_aris
|
47
|
+
end
|
29
48
|
end
|
30
49
|
|
31
50
|
def print_ari(scheme, path, description = nil)
|
@@ -56,29 +75,25 @@ module Abt
|
|
56
75
|
|
57
76
|
private
|
58
77
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
puts(Abt::Docs::Markdown.readme)
|
79
|
-
true
|
80
|
-
else
|
81
|
-
false
|
78
|
+
def global_command?
|
79
|
+
return true if aris.empty?
|
80
|
+
return true if aris.first.scheme.nil?
|
81
|
+
|
82
|
+
false
|
83
|
+
end
|
84
|
+
|
85
|
+
def process_global_command
|
86
|
+
command_class = self.class.global_command_class(command)
|
87
|
+
|
88
|
+
if command_class.nil?
|
89
|
+
abort "No such global command: #{command}, perhaps you forgot to add an ARI?"
|
90
|
+
end
|
91
|
+
|
92
|
+
begin
|
93
|
+
ari = aris.first || Abt::Ari.new
|
94
|
+
command_class.new(cli: self, ari: ari).perform
|
95
|
+
rescue Exit => e
|
96
|
+
puts e.message
|
82
97
|
end
|
83
98
|
end
|
84
99
|
|
@@ -13,6 +13,13 @@ module Abt
|
|
13
13
|
result = AriList.new
|
14
14
|
rest = arguments.dup
|
15
15
|
|
16
|
+
# If the arguments start with "-" it means that we are parsing flags for a global command
|
17
|
+
if rest.any? && rest.first[0] == '-'
|
18
|
+
flags = take_flags(rest)
|
19
|
+
|
20
|
+
return [Ari.new(flags: flags)]
|
21
|
+
end
|
22
|
+
|
16
23
|
until rest.empty?
|
17
24
|
(scheme, path) = rest.shift.split(':')
|
18
25
|
flags = take_flags(rest)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class Cli
|
5
|
+
module GlobalCommands
|
6
|
+
class Commands < Abt::BaseCommand
|
7
|
+
def self.usage
|
8
|
+
'abt commands'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
'List all abt commands'
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cli
|
16
|
+
|
17
|
+
def perform
|
18
|
+
puts(Abt::Docs::Cli.commands)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class Cli
|
5
|
+
module GlobalCommands
|
6
|
+
class Examples < Abt::BaseCommand
|
7
|
+
def self.usage
|
8
|
+
'abt examples'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
'Print command examples'
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cli
|
16
|
+
|
17
|
+
def perform
|
18
|
+
puts(Abt::Docs::Cli.examples)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class Cli
|
5
|
+
module GlobalCommands
|
6
|
+
class Help < Abt::BaseCommand
|
7
|
+
def self.usage
|
8
|
+
'abt help'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
'Print abt usage text'
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cli
|
16
|
+
|
17
|
+
def perform
|
18
|
+
puts(Abt::Docs::Cli.help)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class Cli
|
5
|
+
module GlobalCommands
|
6
|
+
class Readme < Abt::BaseCommand
|
7
|
+
def self.usage
|
8
|
+
'abt readme'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
'Print markdown readme'
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cli
|
16
|
+
|
17
|
+
def perform
|
18
|
+
puts(Abt::Docs::Markdown.readme)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class Cli
|
5
|
+
module GlobalCommands
|
6
|
+
class Share < Abt::BaseCommand
|
7
|
+
def self.usage
|
8
|
+
'abt share'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
'Prints all project configuration as a single line of ARIs'
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cli
|
16
|
+
|
17
|
+
def perform
|
18
|
+
warn 'Printing project configuration'
|
19
|
+
puts share_string
|
20
|
+
end
|
21
|
+
|
22
|
+
def share_string
|
23
|
+
@share_string ||= begin
|
24
|
+
aris = Abt.schemes.join(' ')
|
25
|
+
|
26
|
+
input = StringIO.new(aris)
|
27
|
+
output = StringIO.new
|
28
|
+
Abt::Cli.new(argv: ['share'], output: output, input: input).perform
|
29
|
+
|
30
|
+
output.string.strip.gsub(/\s+/, ' ')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class Cli
|
5
|
+
module GlobalCommands
|
6
|
+
class Version < Abt::BaseCommand
|
7
|
+
def self.usage
|
8
|
+
'abt version'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
'Print abt version'
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cli
|
16
|
+
|
17
|
+
def perform
|
18
|
+
puts(Abt::VERSION)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/abt/docs.rb
CHANGED
@@ -45,8 +45,24 @@ module Abt
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def providers
|
48
|
-
@providers ||=
|
49
|
-
|
48
|
+
@providers ||= begin
|
49
|
+
providers = {}
|
50
|
+
|
51
|
+
global_command_names = Abt::Cli.global_command_names
|
52
|
+
providers['Global'] = global_command_names.each_with_object({}) do |name, definition|
|
53
|
+
command_class = Abt::Cli.global_command_class(name)
|
54
|
+
full_name = "abt #{name}"
|
55
|
+
|
56
|
+
if command_class.respond_to?(:usage) && command_class.respond_to?(:description)
|
57
|
+
definition[full_name] = [command_class.usage, command_class.description]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Abt.schemes.sort.each_with_object(providers) do |scheme, definition|
|
62
|
+
definition[scheme] = command_definitions(scheme)
|
63
|
+
end
|
64
|
+
|
65
|
+
providers
|
50
66
|
end
|
51
67
|
end
|
52
68
|
|
@@ -14,9 +14,11 @@ module Abt
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def perform
|
17
|
-
|
18
|
-
|
19
|
-
cli.
|
17
|
+
if path != ''
|
18
|
+
cli.print_ari('asana', path)
|
19
|
+
elsif cli.output.isatty
|
20
|
+
warn 'No configuration for project. Did you initialize Asana?'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -14,9 +14,11 @@ module Abt
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def perform
|
17
|
-
|
18
|
-
|
19
|
-
cli.
|
17
|
+
if path != ''
|
18
|
+
cli.print_ari('devops', path)
|
19
|
+
elsif cli.output.isatty
|
20
|
+
warn 'No configuration for project. Did you initialize DevOps?'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -14,9 +14,11 @@ module Abt
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def perform
|
17
|
-
|
18
|
-
|
19
|
-
cli.
|
17
|
+
if path != ''
|
18
|
+
cli.print_ari('harvest', path)
|
19
|
+
elsif cli.output.isatty
|
20
|
+
warn 'No configuration for project. Did you initialize Harvest?'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
data/lib/abt/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.21
|
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-
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -80,6 +80,12 @@ 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/commands.rb"
|
84
|
+
- "./lib/abt/cli/global_commands/examples.rb"
|
85
|
+
- "./lib/abt/cli/global_commands/help.rb"
|
86
|
+
- "./lib/abt/cli/global_commands/readme.rb"
|
87
|
+
- "./lib/abt/cli/global_commands/share.rb"
|
88
|
+
- "./lib/abt/cli/global_commands/version.rb"
|
83
89
|
- "./lib/abt/cli/prompt.rb"
|
84
90
|
- "./lib/abt/docs.rb"
|
85
91
|
- "./lib/abt/docs/cli.rb"
|