Class: EYAML::CLI
- Inherits:
-
Thor
- Object
- Thor
- EYAML::CLI
- Defined in:
- lib/eyaml/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
66 67 68 |
# File 'lib/eyaml/cli.rb', line 66 def self.exit_on_failure? true end |
Instance Method Details
#decrypt(file) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/eyaml/cli.rb', line 25 def decrypt(file) file_path = Pathname.new(file) unless file_path.exist? puts "#{file} doesn't exist" return end = if .fetch(:"key-from-stdin") # Read key from STDIN {private_key: $stdin.gets} else {keydir: .fetch(:keydir, nil)} end eyaml = EYAML.decrypt_file(file, **) if .has_key?("output") output_file = Pathname.new(.fetch(:output)) File.write(output_file, eyaml) return end puts eyaml end |
#encrypt(*files) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/eyaml/cli.rb', line 8 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: .fetch(:keydir, nil) ) puts "Wrote #{bytes_written} bytes to #{file_path}." end end |
#keygen ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/eyaml/cli.rb', line 52 def keygen public_key, private_key = EYAML.generate_keypair( save: .fetch(:write), keydir: .fetch(:keydir, nil) ) puts "Public Key: #{public_key}" puts "Private Key: #{private_key}" unless .fetch(:write) end |