Sha256: e78c16bc8cea2c784903434b920f2d9b3b42c3709e590e31b70fd90473a93274

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

class OpenbdCLI
  def initialize(argv)
    @argv = argv
  end

  def call
    opts = Slop.parse do |o|
      o.banner = "Usage: openbd <method> [arguments] [options]"
      o.on '-v', '--version', 'print the version' do
        puts "openbd_api #{Openbd::VERSION}"
        exit
      end
      o.on '-h', '--help', 'print help' do
        puts o
        exit
      end
    end

    if method_name.nil?
      puts opts
    elsif params.empty?
      puts OpenBD.send(method_name)
    else
      puts OpenBD.send(method_name, params)
    end
  end

  private

  def method_name
    @argv[0]
  end

  def params
    @argv[1..-1]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openbd_api-0.3.0 lib/openbd/openbd_cli.rb