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 |
# File 'lib/keystok/cli.rb', line 12 def run(args = ARGV) = parse(args) access_token = .access_token if .access_token if !access_token && .access_token_filepath access_token = YAML.load_file(.access_token_filepath) end if access_token.nil? puts 'You have to use -c or -f option' exit 1 end client = Keystok::Client.new(access_token) 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: #{.command}" exit 1 end end |