Class: CICI::CLI
- Inherits:
-
Object
- Object
- CICI::CLI
- Defined in:
- lib/cici/cli.rb
Instance Method Summary collapse
- #decrypt ⇒ Object
- #encrypt ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #parse_options ⇒ Object
- #print_help(exit_code) ⇒ Object
- #run_command ⇒ Object
Constructor Details
Instance Method Details
#decrypt ⇒ Object
88 89 90 |
# File 'lib/cici/cli.rb', line 88 def decrypt CICI::Decrypt.new(@ui, @config).start(@options.set) end |
#encrypt ⇒ Object
84 85 86 |
# File 'lib/cici/cli.rb', line 84 def encrypt CICI::Encrypt.new(@ui, @config).start end |
#parse_options ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cici/cli.rb', line 47 def = Options.new .verbose = false .debug = false opt_parser = OptionParser.new do |opts| opts. = 'Usage: cici encrypt|decrypt [options]' opts.on('-v', '--version', 'Print version') do puts CICI::Version.get exit end opts.on('--verbose', 'Verbose output') do .verbose = true end opts.on('--debug', 'Debug output (also turns on verbose)') do .verbose = true .debug = true end opts.on('--set SET_NAME', 'Set to decrypt (Note: option ignored for encrypt command)') do |set_name| .set = set_name end opts.on('-h', '--help', 'Prints this help') do puts opts exit end end help = opt_parser.help .help = help abort(help) if ARGV.empty? opt_parser.parse!(ARGV) end |
#print_help(exit_code) ⇒ Object
42 43 44 45 |
# File 'lib/cici/cli.rb', line 42 def print_help(exit_code) puts @options.help exit exit_code end |
#run_command ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cici/cli.rb', line 30 def run_command case ARGV[0] when 'encrypt' encrypt when 'decrypt' decrypt else @ui.fail('Command invalid.') print_help(1) end end |