Class: Morpheus::Cli::OptionParser
- Inherits:
-
OptionParser
- Object
- OptionParser
- Morpheus::Cli::OptionParser
- Defined in:
- lib/morpheus/cli/option_parser.rb
Overview
an enhanced OptionParser not used yet, maybe ever =o
Instance Attribute Summary collapse
-
#footer ⇒ Object
Returns the value of attribute footer.
-
#hidden_options ⇒ Object
Array of option names to keep out of help message.
Instance Method Summary collapse
- #add_hidden_option(opt_name) ⇒ Object
- #full_help_message ⇒ Object
- #original_to_s ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#footer ⇒ Object
Returns the value of attribute footer.
10 11 12 |
# File 'lib/morpheus/cli/option_parser.rb', line 10 def @footer end |
#hidden_options ⇒ Object
Array of option names to keep out of help message
13 14 15 |
# File 'lib/morpheus/cli/option_parser.rb', line 13 def @hidden_options end |
Instance Method Details
#add_hidden_option(opt_name) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/morpheus/cli/option_parser.rb', line 53 def add_hidden_option(opt_name) opt_array = [opt_name].flatten.compact @hidden_options ||= [] opt_array.each do |val| if !@hidden_options.include?(val) @hidden_options << val end end @hidden_options end |
#full_help_message ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/morpheus/cli/option_parser.rb', line 21 def out = "" #out << original_to_s if out << "#{}".sub(/\n?\z/, "\n") end if !self.to_a.empty? #out << "Options:\n" # the default way.. # out << summarize().join("") # super hacky, should be examining the option, not the fully formatted description my_summaries = summarize() summarize().each do |opt_description| is_hidden = (@hidden_options || []).find { |hidden_switch| opt_description.include?("--#{hidden_switch}") } if !is_hidden out << opt_description end end end if # nice_footer = footer.split("\n").collect {|line| "#{summary_indent}#{line}" }.join("\n") = out << "\n" out << "#{}".sub(/\n?\z/, "\n") # out << "\n" end out end |
#original_to_s ⇒ Object
15 |
# File 'lib/morpheus/cli/option_parser.rb', line 15 alias :original_to_s :to_s |
#to_s ⇒ Object
17 18 19 |
# File 'lib/morpheus/cli/option_parser.rb', line 17 def to_s end |