Class: GLI::Commands::HelpModules::ArgNameFormatter
- Inherits:
-
Object
- Object
- GLI::Commands::HelpModules::ArgNameFormatter
- Defined in:
- lib/gli/commands/help_modules/arg_name_formatter.rb
Overview
Handles wrapping text
Instance Method Summary collapse
- #format(arguments_description, arguments_options, arguments) ⇒ Object
- #format_argname(arguments_description, arguments_options) ⇒ Object
- #format_arguments(arguments) ⇒ Object
Instance Method Details
#format(arguments_description, arguments_options, arguments) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/gli/commands/help_modules/arg_name_formatter.rb', line 6 def format(arguments_description,,arguments) # Select which format to use: argname or arguments # Priority to old way: argname desc = format_argname(arguments_description, ) desc = format_arguments(arguments) if desc.strip == '' desc end |
#format_argname(arguments_description, arguments_options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gli/commands/help_modules/arg_name_formatter.rb', line 33 def format_argname(arguments_description,) return '' if String(arguments_description).strip == '' desc = arguments_description if .include? :optional desc = "[#{desc}]" end if .include? :multiple desc = "#{desc}..." end " " + desc end |
#format_arguments(arguments) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gli/commands/help_modules/arg_name_formatter.rb', line 14 def format_arguments(arguments) return '' if arguments.empty? desc = "" # Go through the arguments, building the description string arguments.each do |arg| arg_desc = "#{arg.name}" if arg.optional? arg_desc = "[#{arg_desc}]" end if arg.multiple? arg_desc = "#{arg_desc}..." end desc = desc + " " + arg_desc end desc end |