Sha256: 7b2ae43d76a98fca1df6bc3218a600a4346f5592d6a851e85afd2d43404dfc91

Contents?: true

Size: 918 Bytes

Versions: 2

Compression:

Stored size: 918 Bytes

Contents

require 'optparse'

module Vedeu
  class Configuration
    def self.configure(args = [])
      new(args).configure
    end

    def initialize(args = [])
      @args    = args
      @options = {}
    end

    def configure
      parser = OptionParser.new do |opts|
        opts.banner = "Usage: #{$PROGRAM_NAME} [options]"

        opts.on('-1', '--run-once', 'Run application once.') do
          options[:interactive] = false
        end

        opts.on('-c', '--cooked', 'Run application in cooked mode.') do
          options[:mode] = :cooked
        end

        opts.on('-r', '--raw', 'Run application in raw mode (default).') do
          options[:mode] = :raw
        end

        opts.on('-d', '--debug', 'Run application with debugging on.') do
          options[:debug] = true
        end
      end
      parser.parse!(args)

      options
    end

    private

    attr_accessor :args, :options
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.9 lib/vedeu/configuration.rb
vedeu-0.1.8 lib/vedeu/configuration.rb