Sha256: 1719fb54ec1fc3423d82c6fa66ae0c9620f33746c43a8a918940255ded5b54e4
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
#!/usr/bin/env ruby require 'corespring-ruby' require 'json' require 'optparse' options = { action: ARGV[0], secret: nil, client_id: nil } global_opts = nil parser = OptionParser.new do |opts| global_opts = opts opts.banner = [ "Usage: corespring [action] [options]", " Actions:", " token: Returns an api token using client_id and secret", " Options:" ].join("\n") opts.on('--secret secret', 'Secret') do |secret| options[:secret] = secret end opts.on('--client_id client_id', 'Client ID') do |client_id| options[:client_id] = client_id end opts.on('-h', '--help', 'Displays Help') do options[:help] = true puts opts exit end opts.on('--options options', 'Options to encrypt') do |value| options[:options] = JSON.parse(value) end end parser.parse! begin config = YAML::load(File.open(ENV['HOME'] + '/.corespring')) if (options[:client_id].nil?) options[:client_id] = config['client_id'] end if (options[:secret].nil?) options[:secret] = config['secret'] end rescue Errno::ENOENT rescue Psych::SyntaxError puts "YAML configuration file contains invalid syntax. Using defaults." end if (options[:action].nil?) puts global_opts elsif (options[:action] == 'token') client = CoreSpring::APIClient.new(options[:client_id], options[:secret]) puts client.get_token elsif (options[:action] == 'encrypt') client = CoreSpring::APIClient.new(options[:client_id], options[:secret]) puts client.encrypt(options[:options]) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
corespring-0.0.4 | bin/corespring |
corespring-0.0.1 | bin/corespring |