Sha256: 75b8f6f2066629320cb8365553f883f4641ca3a0289f0623cc19d1317e6144f3

Contents?: true

Size: 482 Bytes

Versions: 1

Compression:

Stored size: 482 Bytes

Contents

require 'optparse'

module CLI
  def self.app(&block)
    App.new(ARGV, &block)
  end

  class App
    attr_reader :argv, :opts

    def initialize(argv, &block)
      @argv = argv
      instance_eval(&block)
    end
    
    def options(&block)
      @opts = OptionParser.new
      instance_eval(&block)
      @opts.parse!
    end

    def run(&block)
      instance_eval(&block)
    end

    def name(value) @name = value end
    def version(value) @version = value end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wojtekmach-cli-0.0.1 lib/cli.rb