Class: Vaulty::CLI::Add
Instance Attribute Summary collapse
-
#catacomb ⇒ Object
readonly
Returns the value of attribute catacomb.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(catacomb:, data: {}, files: {}) ⇒ Add
constructor
A new instance of Add.
Methods inherited from Command
#banner, call, #prompt, #table
Constructor Details
#initialize(catacomb:, data: {}, files: {}) ⇒ Add
Returns a new instance of Add.
8 9 10 11 12 |
# File 'lib/vaulty/cli/add.rb', line 8 def initialize(catacomb:, data: {}, files: {}) @catacomb = catacomb files_with_content = read_file_contents!(files) @data = data.merge(files_with_content) end |
Instance Attribute Details
#catacomb ⇒ Object (readonly)
Returns the value of attribute catacomb.
4 5 6 |
# File 'lib/vaulty/cli/add.rb', line 4 def catacomb @catacomb end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/vaulty/cli/add.rb', line 4 def data @data end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vaulty/cli/add.rb', line 14 def call ("Current value #{catacomb.path.inspect}") # Print out the current state table(catacomb.read, highlight: { matching: matching_keys, color: :red }) # If we have matching keys and we don't want to continue, we exit return if matching_keys.any? && prompt.no?('Existing secret found, overwrite?') # Print we are writing and merge the content ("Writing data to #{catacomb.path.inspect}", color: :red) catacomb.merge(data) # Print the final state in a table highlight the values we added table(catacomb.read, highlight: { matching: data.values, color: :green }) end |