Sha256: 8283924b92c14904e6ee0aa66cf187b7ab2f3506bcf5aed3e5545a9fc5387c44

Contents?: true

Size: 775 Bytes

Versions: 6

Compression:

Stored size: 775 Bytes

Contents

module Boson
  class OptionParser
    module MoreOptionParser
      # Given options to pass to OptionParser.new, this method parses ARGV and
      # returns the remaining arguments and a hash of parsed options. This is
      # useful for scripts outside of Boson.
      def parse(options, args=ARGV)
        @opt_parser ||= new(options)
        parsed_options = @opt_parser.parse(args)
        [@opt_parser.non_opts, parsed_options]
      end

      # Usage string summarizing options defined in parse
      def usage
        @opt_parser.to_s
      end

      def make_mergeable!(opts)
        opts.each {|k,v|
          if !v.is_a?(Hash) && !v.is_a?(Symbol)
            opts[k] = {:default=>v}
          end
        }
      end
    end
    extend MoreOptionParser
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
boson-more-0.3.1 lib/boson/more_option_parser.rb
boson-more-0.3.0 lib/boson/more_option_parser.rb
boson-more-0.2.2 lib/boson/more_option_parser.rb
boson-more-0.2.1 lib/boson/more_option_parser.rb
boson-more-0.2.0 lib/boson/more_option_parser.rb
boson-more-0.1.0 lib/boson/more_option_parser.rb