Sha256: dfcc83ce219bf7167e825364bdd0999df43650df5bcb531fe6cf8b6e1f274fec

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

require 'optparse'

module Rallycat
  class CLI
    def initialize(argv, stdout=STDOUT)
      @argv   = argv
      @stdout = stdout
    end

    def run
      options = {}
      option_parser = OptionParser.new do |opts|
        opts.on('-u USER') do |user|
          options[:user] = user
        end

        opts.on('-p PASSWORD') do |password|
          options[:password] = password
        end
      end

      option_parser.parse! @argv

      case @argv.shift
      when 'cat'
        api = Rallycat::Connection.new(options[:user], options[:password]).api

        @stdout.puts Rallycat::Cat.new(api).story(@argv.shift)
      else
        @stdout.puts 'only support for `cat` exists at the moment.'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rallycat-0.1.0 lib/rallycat/cli.rb