Class: Keystok::CLI
- Inherits:
-
Object
- Object
- Keystok::CLI
- Defined in:
- lib/keystok/cli.rb
Overview
Parses command line arguments and execute requested actions
Instance Method Summary collapse
Instance Method Details
#run(args = ARGV) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/keystok/cli.rb', line 12 def run(args = ARGV) = parse(args) if .connection_string connection_string = .connection_string end if !connection_string && .connection_string_filepath connection_string = YAML.load_file( .connection_string_filepath)['connection_string'] end if connection_string.nil? puts 'You have to use -c or -f option' exit 1 end client = Keystok::Client.new(connection_string) case .command when :dump puts dump_data(client.keys, .dump_format) when :get if .key_id puts client.get(.key_id) else puts format_keys_list(client.keys) end else puts "Unknown command: #{options.command}" exit 1 end end |