Sha256: 3b4f4873b5967bca8ad99351fbe31942a5a6890a5873ab6fb06fa031b3457a7b
Contents?: true
Size: 557 Bytes
Versions: 1
Compression:
Stored size: 557 Bytes
Contents
# frozen_string_literal: true require "optparse" ## # An OptionParser wrapper providing a few convenience functions. class SimpleOpts < OptionParser def initialize(*args, defaults: nil) super(*args) @okay_options = defaults || {} end # simple(..., :a) # simple(..., :b) # == # options = {} # on(...) { |val| options[:a] = val } # on(...) { |val| options[:b] = val } def simple(*args) key = args.pop on(*args) { |*x| @okay_options[key] = x[0] } end def parse(args) parse!(args.dup) @okay_options end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
okay-10.0.0 | lib/okay/simple_opts.rb |