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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a564bac0dc6d8ba790b99238519dd12c2e1efea7fccfbf832a69e9861cb98f7
4
- data.tar.gz: 502c1bb72096256a854631bf375a30f917f04fd636b28e186ce5b5294f8830e5
3
+ metadata.gz: 62e332544af0910c66dda052deace55c038f308734a6f61327338c02bd6d0c6c
4
+ data.tar.gz: 8e436c956c7713519b6ade1085866b1669d42b6a26bbdc4655151e7b0f295017
5
5
  SHA512:
6
- metadata.gz: 8a508c3a12446379ba2947d78950f506214ee3c0f8240279cbc09592f44b119af150611a6d1addb18d5173cdb877da95ea9d1553ce0a0b2eef448b963abc47b2
7
- data.tar.gz: 87c3e9ba9f42a2c5372b40a16bc7b8ce33042d34955e9ac65dff6fede1169be9214644c2d91f8b15d7e6d3eed19b1274a79c75cf2c6ac8e8f8d20d12b424f722
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
- ALIASES = Hash.new { |_, k| k }.update(
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 = (ALIASES.keys + BUILTIN_CMDS + KBSecret::CLI::Command.command_names + EXT_CMDS).freeze
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 alias?(cmd)
59
- ALIASES.keys.include?(cmd)
58
+ def flag?(cmd)
59
+ FLAGS.keys.include?(cmd)
60
60
  end
61
61
 
62
62
  def normalize(cmd)
63
- ALIASES[cmd]
63
+ KBSecret::Config.unalias_command(FLAGS[cmd])
64
64
  end
65
65
 
66
66
  def expand(cmd)
67
- return cmd if alias?(cmd) || builtin?(cmd)
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: '#{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: '#{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!
@@ -22,7 +22,7 @@ module KBSecret
22
22
  def run!
23
23
  Config.session_labels.each do |sess_name|
24
24
  session_hash = Config.session(sess_name)
25
- session = cli.guard { Session[sess_name] }
25
+ session = cli.guard { KBSecret::Session[sess_name] }
26
26
 
27
27
  puts sess_name
28
28
 
@@ -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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module KBSecret
4
4
  # kbsecret's current version
5
- VERSION = "1.3.0.pre.1"
5
+ VERSION = "1.3.0.pre.2"
6
6
  end
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.1
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-30 00:00:00.000000000 Z
11
+ date: 2018-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba