Module: Trustworthy::CLI::Crypt
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
4 5 6 |
# File 'lib/trustworthy/cli/crypt.rb', line 4 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#_check_options(args) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/trustworthy/cli/crypt.rb', line 34 def (args) = (args) unless .has_key?(:input_file) && .has_key?(:output_file) print_help throw :error end end |
#_command ⇒ Object
30 31 32 |
# File 'lib/trustworthy/cli/crypt.rb', line 30 def _command self.class._command end |
#parse_options(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/trustworthy/cli/crypt.rb', line 8 def (args) super(_command, args) do |opts, | opts.on('-i', '--input FILE', "File to #{_command}") do |file| [:input_file] = file end opts.on('-o', '--output FILE', "File to write #{_command}ed contents to") do |file| [:output_file] = file end end end |
#run(args) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/trustworthy/cli/crypt.rb', line 20 def run(args) catch(:error) do = (args) prompt = Trustworthy::Prompt.new([:config_file], $terminal) File.open([:input_file], 'rb') do |input_file| _transform(prompt, , input_file) end end end |