Module: ChefApply::CLI::Help
- Included in:
- ChefApply::CLI
- Defined in:
- lib/chef_apply/cli/help.rb
Constant Summary collapse
Instance Method Summary collapse
- #format_flags ⇒ Object
- #format_help ⇒ Object
- #show_help ⇒ Object
- #show_version ⇒ Object
- #usage ⇒ Object
Instance Method Details
#format_flags ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/chef_apply/cli/help.rb', line 32 def format_flags flag_text = "FLAGS:\n" justify_length = 0 .each_value do |spec| justify_length = [justify_length, spec[:long].length + 4].max end .sort.to_h.each_value do |flag_spec| short = flag_spec[:short] || " " short = short[0, 2] # We only want the flag portion, not the capture portion (if present) if short == " " short = " " else short = "#{short}, " end flags = "#{short}#{flag_spec[:long]}" flag_text << " #{flags.ljust(justify_length)} " ml_padding = " " * (justify_length + 8) first = true flag_spec[:description].split("\n").each do |d| flag_text << ml_padding unless first first = false flag_text << "#{d}\n" end end flag_text end |
#format_help ⇒ Object
26 27 28 29 30 |
# File 'lib/chef_apply/cli/help.rb', line 26 def format_help help_text = .clone # This prevents us appending to the banner text help_text << "\n" help_text << format_flags end |
#show_help ⇒ Object
22 23 24 |
# File 'lib/chef_apply/cli/help.rb', line 22 def show_help UI::Terminal.output format_help end |
#show_version ⇒ Object
63 64 65 66 |
# File 'lib/chef_apply/cli/help.rb', line 63 def show_version require_relative "../version" UI::Terminal.output T.version.show(ChefApply::VERSION) end |
#usage ⇒ Object
59 60 61 |
# File 'lib/chef_apply/cli/help.rb', line 59 def usage T.usage end |