Sha256: 267fa4e8de45d826656ba38508f79050066a2a1399756f0f056843b841f707db

Contents?: true

Size: 801 Bytes

Versions: 8

Compression:

Stored size: 801 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
      end
      parser.parse!(args)

      options
    end

    private

    attr_accessor :args, :options
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.1.1 lib/vedeu/configuration.rb
vedeu-0.1.0 lib/vedeu/configuration.rb
vedeu-0.0.42 lib/vedeu/configuration.rb
vedeu-0.0.41 lib/vedeu/configuration.rb
vedeu-0.0.40 lib/vedeu/configuration.rb
vedeu-0.0.39 lib/vedeu/configuration.rb
vedeu-0.0.38 lib/vedeu/configuration.rb
vedeu-0.0.37 lib/vedeu/configuration.rb