Sha256: 18e433914a4d2432f941787ac1d649c469f8127d10795a4e8fc4fcf1f5765c64
Contents?: true
Size: 1003 Bytes
Versions: 2
Compression:
Stored size: 1003 Bytes
Contents
# encoding: UTF-8 require 'anvil/task' require 'anvil/options_detector' module Anvil # Parser for anvil command line arguments and options class Parser < OptionParser attr_accessor :options attr_accessor :task def options @options ||= {} end def arguments(args = nil) return @arguments if @arguments @arguments = [args.presence].compact.flatten end def banner unless @banner @banner = banner_string visit(:add_banner, @banner) end @banner end def banner_string args = arguments.map(&:upcase).join(' ') message = "Usage: anvil #{task.task_name}" message += " #{args}" unless args.empty? message += ' [options]' message end def from(name) task_klass = Anvil::Task.from_name(name) instance_eval(&task_klass.parser_block) if task_klass.parser_block end def detect_options(&block) OptionsDetector.new.detect_options(&block) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anvil-core-0.6.0 | lib/anvil/parser.rb |
anvil-core-0.5.0 | lib/anvil/parser.rb |