Class: SecretKeys::CLI::Read
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#format, #initialize, #secrets
Constructor Details
This class inherits a constructor from SecretKeys::CLI::Base
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
253 254 255 |
# File 'lib/secret_keys/cli.rb', line 253 def key @key end |
Instance Method Details
#action_name ⇒ Object
255 256 257 |
# File 'lib/secret_keys/cli.rb', line 255 def action_name "read" end |
#parse_additional_options(opts) ⇒ Object
259 260 261 262 263 264 265 |
# File 'lib/secret_keys/cli.rb', line 259 def (opts) opts.separator("\n Read options:") @key = nil opts.on("-k", "--key KEY", String, "Key from the file to output. You can use dot notation to read a nested key.") do |value| @key = value end end |
#run! ⇒ Object
267 268 269 270 271 272 273 |
# File 'lib/secret_keys/cli.rb', line 267 def run! raise ArgumentError.new("key is required") if @key.nil? || @key.empty? val = secrets.to_h val = access_key(val, @key) { |parent, key| parent[key] } $stdout.write(val) $stdout.flush end |