Sha256: 430fbfa26ac630752fdfc6bcd163f1df7a2a8d4263912b85db9ba475d8f9be47

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

module EdgeCastToken
  class CLI
    def self.main
      @options = {}

      option_parser = OptionParser.new do |opts|
        opts.on('-k', '--key=KEY', 'Key to encrypt or decrypt') do |v|
          @options[:key] = v
        end

        opts.on('-t', '--token=TOKEN', 'Token to encrypt or decrypt') do |v|
          @options[:token] = v
        end

        opts.on('-d', '--decrypt', 'Use this option to decrypt data') do |v|
          @options[:decrypt] = true
        end
      end

      option_parser.parse!

      if @options[:key].nil? || @options[:token].nil?
        puts option_parser.help
        exit 1
      end

      case @options[:decrypt].nil?
      when true
        puts Token.encrypt(@options[:key], @options[:token])
      when false
        puts Token.decrypt(@options[:key], @options[:token])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
verizon_token-0.2.1 lib/ectoken/cli.rb
verizon_token-0.2.0 lib/ectoken/cli.rb
verizon_token-0.1.0 lib/ectoken/cli.rb