Method: OptParseBuilder.build_bundle
- Defined in:
- lib/opt_parse_builder.rb
.build_bundle {|bundler| ... } ⇒ Object
Build a bundle of arguments that can be added to a parser together. Yields an ArgumentBundleBuilder.
This is useful when you have a group of arguments that go together:
bundle = OptParseBuilder.build_bundle do |args|
args.add do |arg|
arg.key :x
op.on "-x", Integer, "X coordinate"
end
args.add do |arg|
arg.key :y
op.on "-y", Integer, "Y coordinate"
end
end
arg_parser = OptParseBuilder.build_parser do |args|
args.add bundle
end
Raises BuildError if the argument cannot be built or added.
This is most useful when you are building a related suite of programs that share some command-line arguments in common. Most of the time you will just add the arguments using the block form of OptParseBuilder#add.
150 151 152 153 154 |
# File 'lib/opt_parse_builder.rb', line 150 def self.build_bundle bundler = ArgumentBundleBuilder.new yield bundler bundler.argument end |