class SecretKeys::CLI::Init

Public Instance Methods

action_name() click to toggle source
# File lib/secret_keys/cli.rb, line 161
def action_name
  "init"
end
run!() click to toggle source
# File lib/secret_keys/cli.rb, line 165
def run!
  @secrets = SecretKeys.new({}, secret_key)
  if input.is_a?(String)
    if File.exist?(input)
      STDERR.puts "Error: Cannot init preexisting file '#{input}'"
      STDERR.puts "You may want to try calling `secret_keys encrypt/edit` instead"
      exit 1
    end

    File.write(input, encrypted_file_contents)
  else
    $stdout.write(encrypted_file_contents)
  end
end