kbsecret 1.3.0.pre.1 → 1.3.0.pre.2
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 +4 -4
- data/bin/kbsecret +8 -8
- data/lib/kbsecret/cli/command/abstract.rb +5 -0
- data/lib/kbsecret/cli/command/sessions.rb +1 -1
- data/lib/kbsecret/config.rb +15 -0
- data/lib/kbsecret/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62e332544af0910c66dda052deace55c038f308734a6f61327338c02bd6d0c6c
|
|
4
|
+
data.tar.gz: 8e436c956c7713519b6ade1085866b1669d42b6a26bbdc4655151e7b0f295017
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22f83a0907bdd794f823ae45c8ad9a264a5083221a483eaa0f26322383f695d7c01d172158e3770b32c220ac95a29cd7942f7c5584e4d6f5d953d50a19c48649
|
|
7
|
+
data.tar.gz: 54112352f2a7b65a20deac137aaa52623f286d2e158dbf22d0c27c49ad5b3e3f444067a765ac8ff441dc3ea3d4a6e1d2832f532e2419a34cc3eb730301a425f1
|
data/bin/kbsecret
CHANGED
|
@@ -14,14 +14,14 @@ EXT_CMDS = EXT_PATHS.map do |c|
|
|
|
14
14
|
File.basename(c, File.extname(c)).sub!("kbsecret-", "")
|
|
15
15
|
end.freeze
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
FLAGS = Hash.new { |_, k| k }.update(
|
|
18
18
|
"--help" => "help",
|
|
19
19
|
"-h" => "help",
|
|
20
20
|
"--version" => "version",
|
|
21
21
|
"-v" => "version"
|
|
22
22
|
).freeze
|
|
23
23
|
|
|
24
|
-
ALL_CMDS = (
|
|
24
|
+
ALL_CMDS = (FLAGS.keys + BUILTIN_CMDS + KBSecret::CLI::Command.command_names + EXT_CMDS).freeze
|
|
25
25
|
|
|
26
26
|
KBSECRET_HELP = <<~KBSECRET_HELP
|
|
27
27
|
Usage:
|
|
@@ -55,16 +55,16 @@ def builtin?(cmd)
|
|
|
55
55
|
BUILTIN_CMDS.include?(cmd)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def
|
|
59
|
-
|
|
58
|
+
def flag?(cmd)
|
|
59
|
+
FLAGS.keys.include?(cmd)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def normalize(cmd)
|
|
63
|
-
|
|
63
|
+
KBSecret::Config.unalias_command(FLAGS[cmd])
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def expand(cmd)
|
|
67
|
-
return cmd if
|
|
67
|
+
return cmd if flag?(cmd) || builtin?(cmd)
|
|
68
68
|
|
|
69
69
|
"kbsecret-#{cmd}"
|
|
70
70
|
end
|
|
@@ -80,7 +80,7 @@ def help(*args)
|
|
|
80
80
|
elsif external? command
|
|
81
81
|
KBSecret::CLI.die "Help is not available for external commands."
|
|
82
82
|
else
|
|
83
|
-
KBSecret::CLI.die "Unknown command:
|
|
83
|
+
KBSecret::CLI.die "Unknown command: #{command}."
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -143,5 +143,5 @@ elsif internal?(command)
|
|
|
143
143
|
elsif external?(command)
|
|
144
144
|
exec expand(command), *args
|
|
145
145
|
else
|
|
146
|
-
KBSecret::CLI.die "Unknown command:
|
|
146
|
+
KBSecret::CLI.die "Unknown command: #{command}."
|
|
147
147
|
end
|
|
@@ -28,6 +28,11 @@ module KBSecret
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
# @return [Hash, nil] the configuration for the command, if any.
|
|
32
|
+
def self.config
|
|
33
|
+
KBSecret::Config.command(command_name)
|
|
34
|
+
end
|
|
35
|
+
|
|
31
36
|
# Sets up any state used by the command. Implemented by children.
|
|
32
37
|
# @abstract
|
|
33
38
|
def setup!
|
data/lib/kbsecret/config.rb
CHANGED
|
@@ -95,6 +95,21 @@ module KBSecret
|
|
|
95
95
|
@command_config.dig(cmd, "args")&.shellsplit || []
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
+
# Attempt to resolve an alias into a `kbsecret` command.
|
|
99
|
+
# @param acmd [String] the command alias
|
|
100
|
+
# @return [String] the `kbsecret` command, or `acmd` if the alias does not exist
|
|
101
|
+
# @example
|
|
102
|
+
# Config.unalias_command("l") # => "list"
|
|
103
|
+
# Config.unalias_command("madeup") # => "madeup"
|
|
104
|
+
def self.unalias_command(acmd)
|
|
105
|
+
@command_config.each do |cmd, conf|
|
|
106
|
+
aliases = conf["aliases"]&.split || []
|
|
107
|
+
return cmd if aliases.include?(acmd)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
acmd
|
|
111
|
+
end
|
|
112
|
+
|
|
98
113
|
# @!method session(label)
|
|
99
114
|
# Retrieve a session's configuration.
|
|
100
115
|
# @param label [String, Symbol] the session's label
|
data/lib/kbsecret/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kbsecret
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.0.pre.
|
|
4
|
+
version: 1.3.0.pre.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- William Woodruff
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-03-
|
|
11
|
+
date: 2018-03-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aruba
|