Class: Vaulty::CLI::Remove
Instance Attribute Summary collapse
-
#catacomb ⇒ Object
readonly
Returns the value of attribute catacomb.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(catacomb:, keys:) ⇒ Remove
constructor
A new instance of Remove.
Methods inherited from Command
#banner, call, #prompt, #table
Constructor Details
#initialize(catacomb:, keys:) ⇒ Remove
Returns a new instance of Remove.
5 6 7 8 |
# File 'lib/vaulty/cli/remove.rb', line 5 def initialize(catacomb:, keys:) @catacomb = catacomb @keys = keys end |
Instance Attribute Details
#catacomb ⇒ Object (readonly)
Returns the value of attribute catacomb.
4 5 6 |
# File 'lib/vaulty/cli/remove.rb', line 4 def catacomb @catacomb end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
4 5 6 |
# File 'lib/vaulty/cli/remove.rb', line 4 def keys @keys end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vaulty/cli/remove.rb', line 10 def call found_keys = Array(catacomb.matching_keys(keys)) raise Vaulty::MissingKeys.new(catacomb.path, keys) if found_keys.empty? ("Found keys #{found_keys.join(', ')} at #{catacomb.path.inspect}") table(catacomb.read, highlight: { matching: found_keys, color: :red }) return if prompt.no?('All above data will be deleted! Are you sure?', color: :red) delete_keys(found_keys) prompt.ok("Successfully deleted keys #{found_keys.join(', ')} at #{catacomb.path.inspect}") end |