Class: Arcanus::Command::Edit
- Includes:
- Shared::EnsureKey
- Defined in:
- lib/arcanus/command/edit.rb
Instance Method Summary collapse
Methods included from Shared::EnsureKey
Methods inherited from Base
description, #execute_command, from_arguments, #initialize, #run, short_name
Methods included from Utils
camel_case, deep_dup, snake_case
Constructor Details
This class inherits a constructor from Arcanus::Command::Base
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/arcanus/command/edit.rb', line 10 def execute ensure_key_unlocked unless editor_defined? raise Arcanus::Errors::ConfigurationError, '$EDITOR environment variable is not defined' end key = Arcanus::Key.from_file(repo.unlocked_key_path) chest = Arcanus::Chest.new(key: key, chest_file_path: repo.chest_file_path) if arguments.size > 1 edit_single_key(chest, arguments[1], arguments[2]) else # Edit entire chest ::Tempfile.new(['arcanus-chest', '.yaml']).tap do |file| file.sync = true file.write(chest.to_yaml) edit_until_done(chest, file.path) end end end |