Class: SimpleScripting::Argv::ExitWithArgumentsHelpPrinting
- Inherits:
-
Struct
- Object
- Struct
- SimpleScripting::Argv::ExitWithArgumentsHelpPrinting
- Defined in:
- lib/simple_scripting/argv.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#commands_stack ⇒ Object
Returns the value of attribute commands_stack.
-
#parser_opts_copy ⇒ Object
Returns the value of attribute parser_opts_copy.
Instance Method Summary collapse
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
30 31 32 |
# File 'lib/simple_scripting/argv.rb', line 30 def args @args end |
#commands_stack ⇒ Object
Returns the value of attribute commands_stack
30 31 32 |
# File 'lib/simple_scripting/argv.rb', line 30 def commands_stack @commands_stack end |
#parser_opts_copy ⇒ Object
Returns the value of attribute parser_opts_copy
30 31 32 |
# File 'lib/simple_scripting/argv.rb', line 30 def parser_opts_copy @parser_opts_copy end |
Instance Method Details
#print_help(output, long_help) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/simple_scripting/argv.rb', line 31 def print_help(output, long_help) parser_opts_help = parser_opts_copy.to_s if commands_stack.size > 0 parser_opts_help = parser_opts_help.sub!('[options]', commands_stack.join(' ') + ' [options]') end if args.size > 0 args_display = args.map { |name, mandatory| mandatory ? "<#{ name }>" : "[<#{ name }>]" }.join(' ') parser_opts_help = parser_opts_help.sub!(/^(Usage: .*)/) { |text| "#{text} #{args_display}" } end output.puts parser_opts_help output.puts "", long_help if long_help end |