abt-cli 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/abt +1 -1
- data/lib/abt.rb +5 -0
- data/lib/abt/cli.rb +28 -9
- data/lib/abt/directory_config.rb +25 -0
- data/lib/abt/providers/asana/configuration.rb +11 -3
- data/lib/abt/providers/devops/configuration.rb +1 -1
- data/lib/abt/providers/harvest/configuration.rb +1 -1
- data/lib/abt/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed527a89749355f223b94daa60d63b91c78ae98ab6976c3470ec6ca42cbcff27
|
4
|
+
data.tar.gz: aed24bd58e30bfbbdc574532eb97044cd8e108851c2586ac407c0eb42a2deb28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d615f241ac406df5f89cc79ad36f19b0554602f6eb3e20e2f01ba0143595ea6e748c727ccedfeecd1a826c46e031acc7160a3b0ee7462027157a357d730de35
|
7
|
+
data.tar.gz: 2b9e500f77e181f4198ac17939fc1753f9a7105682783b005d780ec4da61c8af43aa3e986bba34e1df4f5173bde47bd0e97e042f293edb713a364d2a9c1c71b6
|
data/bin/abt
CHANGED
data/lib/abt.rb
CHANGED
@@ -6,6 +6,7 @@ require "oj"
|
|
6
6
|
require "open3"
|
7
7
|
require "stringio"
|
8
8
|
require "optparse"
|
9
|
+
require "yaml"
|
9
10
|
|
10
11
|
Dir.glob("#{File.dirname(File.absolute_path(__FILE__))}/abt/*.rb").sort.each do |file|
|
11
12
|
require file
|
@@ -22,4 +23,8 @@ module Abt
|
|
22
23
|
const_name = Helpers.command_to_const(scheme)
|
23
24
|
Providers.const_get(const_name) if Providers.const_defined?(const_name)
|
24
25
|
end
|
26
|
+
|
27
|
+
def self.directory_config
|
28
|
+
@directory_config ||= Abt::DirectoryConfig.new
|
29
|
+
end
|
25
30
|
end
|
data/lib/abt/cli.rb
CHANGED
@@ -5,20 +5,19 @@ Dir.glob("#{File.expand_path(__dir__)}/cli/*.rb").sort.each do |file|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module Abt
|
8
|
-
class Cli
|
8
|
+
class Cli # rubocop:disable Metrics/ClassLength
|
9
9
|
class Abort < StandardError; end
|
10
10
|
|
11
11
|
class Exit < StandardError; end
|
12
12
|
|
13
|
-
attr_reader :command, :
|
13
|
+
attr_reader :command, :remaining_args, :input, :output, :err_output, :prompt
|
14
14
|
|
15
15
|
def initialize(argv: ARGV, input: $stdin, output: $stdout, err_output: $stderr)
|
16
|
-
(@command,
|
16
|
+
(@command, *@remaining_args) = argv
|
17
17
|
@input = input
|
18
18
|
@output = output
|
19
19
|
@err_output = err_output
|
20
20
|
@prompt = Abt::Cli::Prompt.new(output: err_output)
|
21
|
-
@aris = ArgumentsParser.new(sanitized_piped_args + remaining_args).parse
|
22
21
|
end
|
23
22
|
|
24
23
|
def perform
|
@@ -27,11 +26,10 @@ module Abt
|
|
27
26
|
@command = "help"
|
28
27
|
end
|
29
28
|
|
30
|
-
if
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
29
|
+
return process_alias if alias?
|
30
|
+
return process_global_command if global_command?
|
31
|
+
|
32
|
+
process_aris
|
35
33
|
end
|
36
34
|
|
37
35
|
def print_ari(scheme, path, description = nil)
|
@@ -60,8 +58,29 @@ module Abt
|
|
60
58
|
raise Exit, message
|
61
59
|
end
|
62
60
|
|
61
|
+
def aris
|
62
|
+
@aris ||= ArgumentsParser.new(sanitized_piped_args + remaining_args).parse
|
63
|
+
end
|
64
|
+
|
63
65
|
private
|
64
66
|
|
67
|
+
def alias?
|
68
|
+
command[0] == "@"
|
69
|
+
end
|
70
|
+
|
71
|
+
def process_alias
|
72
|
+
matching_alias = Abt.directory_config.dig("aliases", command[1..-1])
|
73
|
+
|
74
|
+
abort("No such alias #{command}") if matching_alias.nil?
|
75
|
+
|
76
|
+
with_args = matching_alias.sub("$@", remaining_args.join(" "))
|
77
|
+
with_program_name = with_args.gsub("$0", $PROGRAM_NAME).strip
|
78
|
+
humanized = with_args.gsub("$0", "abt").strip
|
79
|
+
|
80
|
+
warn(humanized)
|
81
|
+
system(with_program_name)
|
82
|
+
end
|
83
|
+
|
65
84
|
def global_command?
|
66
85
|
return true if aris.empty?
|
67
86
|
return true if aris.first.scheme.nil?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abt
|
4
|
+
class DirectoryConfig < Hash
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
merge!(YAML.load_file(config_file_path)) if config_file_path
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def config_file_path
|
13
|
+
dir = Dir.pwd
|
14
|
+
|
15
|
+
until File.exist?(File.join(dir, ".abt.yml"))
|
16
|
+
next_dir = File.expand_path("..", dir)
|
17
|
+
return if next_dir == dir
|
18
|
+
|
19
|
+
dir = next_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
File.join(dir, ".abt.yml")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -15,7 +15,7 @@ module Abt
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def path
|
18
|
-
Path.new(local_available? && git["path"] || "")
|
18
|
+
Path.new(local_available? && git["path"] || directory_config["path"] || "")
|
19
19
|
end
|
20
20
|
|
21
21
|
def path=(new_path)
|
@@ -36,13 +36,17 @@ module Abt
|
|
36
36
|
def wip_section_gid
|
37
37
|
return nil unless local_available?
|
38
38
|
|
39
|
-
@wip_section_gid ||= git["wipSectionGid"] ||
|
39
|
+
@wip_section_gid ||= git["wipSectionGid"] ||
|
40
|
+
directory_config["wip_section_gid"] ||
|
41
|
+
prompt_wip_section["gid"]
|
40
42
|
end
|
41
43
|
|
42
44
|
def finalized_section_gid
|
43
45
|
return nil unless local_available?
|
44
46
|
|
45
|
-
@finalized_section_gid ||= git["finalizedSectionGid"] ||
|
47
|
+
@finalized_section_gid ||= git["finalizedSectionGid"] ||
|
48
|
+
directory_config["finalized_section_gid"] ||
|
49
|
+
prompt_finalized_section["gid"]
|
46
50
|
end
|
47
51
|
|
48
52
|
def clear_local(verbose: true)
|
@@ -66,6 +70,10 @@ module Abt
|
|
66
70
|
|
67
71
|
private
|
68
72
|
|
73
|
+
def directory_config
|
74
|
+
Abt.directory_config.fetch("asana", {})
|
75
|
+
end
|
76
|
+
|
69
77
|
def git
|
70
78
|
@git ||= GitConfig.new("local", "abt.asana")
|
71
79
|
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.26
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- "./lib/abt/cli/global_commands/share.rb"
|
89
89
|
- "./lib/abt/cli/global_commands/version.rb"
|
90
90
|
- "./lib/abt/cli/prompt.rb"
|
91
|
+
- "./lib/abt/directory_config.rb"
|
91
92
|
- "./lib/abt/docs.rb"
|
92
93
|
- "./lib/abt/docs/cli.rb"
|
93
94
|
- "./lib/abt/docs/markdown.rb"
|