lib/eyaml/cli.rb in eyaml-0.1.0 vs lib/eyaml/cli.rb in eyaml-0.1.1
- old
+ new
@@ -1,28 +1,24 @@
module EYAML
class InvalidFormatError < StandardError; end
class CLI < Thor
- class_option :keydir, aliases: "-k", type: :string, desc: "Directory containing EYAML keys"
-
desc "encrypt", "(Re-)encrypt one or more EYAML files"
def encrypt(*files)
files.each do |file|
file_path = Pathname.new(file)
next unless file_path.exist?
- bytes_written = EYAML.encrypt_file_in_place(
- file_path,
- keydir: options.fetch(:keydir, nil)
- )
+ bytes_written = EYAML.encrypt_file_in_place(file_path)
puts "Wrote #{bytes_written} bytes to #{file_path}."
end
end
method_option :output, type: :string, desc: "print output to the provided file, rather than stdout", aliases: "-o"
method_option :"key-from-stdin", type: :boolean, desc: "read the private key from STDIN", default: false
+ method_option :keydir, type: :string, desc: "Directory containing EYAML keys", aliases: "-k"
desc "decrypt", "Decrypt an EYAML file"
def decrypt(file)
file_path = Pathname.new(file)
unless file_path.exist?
puts "#{file} doesn't exist"
@@ -46,9 +42,10 @@
puts eyaml
end
method_option :write, type: :boolean, aliases: "-w", desc: "rather than printing both keys, print the public and write the private into the keydir", default: false
+ method_option :keydir, type: :string, desc: "Directory containing EYAML keys", aliases: "-k"
desc "keygen", "Generate a new EYAML keypair"
def keygen
public_key, private_key = EYAML.generate_keypair(
save: options.fetch(:write),
keydir: options.fetch(:keydir, nil)