Class: Anvil::Parser
- Inherits:
-
OptionParser
- Object
- OptionParser
- Anvil::Parser
- Defined in:
- lib/anvil/parser.rb
Overview
Parser for anvil command line arguments and options
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
- #arguments(args = nil) ⇒ Object
- #banner ⇒ Object
- #banner_string ⇒ Object
- #detect_options(&block) ⇒ Object
- #from(name) ⇒ Object
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/anvil/parser.rb', line 9 def @options end |
#task ⇒ Object
Returns the value of attribute task.
10 11 12 |
# File 'lib/anvil/parser.rb', line 10 def task @task end |
Instance Method Details
#arguments(args = nil) ⇒ Object
16 17 18 19 |
# File 'lib/anvil/parser.rb', line 16 def arguments(args = nil) return @arguments if @arguments @arguments = [args.presence].compact.flatten end |
#banner ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/anvil/parser.rb', line 21 def unless @banner @banner = visit(:add_banner, @banner) end @banner end |
#banner_string ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/anvil/parser.rb', line 30 def args = arguments.map(&:upcase).join(' ') = "Usage: anvil #{task.task_name}" += " #{args}" unless args.empty? += ' [options]' end |
#detect_options(&block) ⇒ Object
44 45 46 |
# File 'lib/anvil/parser.rb', line 44 def (&block) OptionsDetector.new.(&block) end |