Class: GLI::Commands::Help

Inherits:
GLI::Command show all
Defined in:
lib/gli/commands/help.rb

Overview

The help command used for the two-level interactive help system

Constant Summary collapse

@@skips_pre =
true
@@skips_post =
true
@@skips_around =
true

Constants inherited from GLI::Command

GLI::Command::PARENT

Instance Attribute Summary

Attributes included from GLI::CommandSupport

#parent

Attributes inherited from GLI::CommandLineToken

#aliases, #description, #long_description, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GLI::Command

#action, #default_command, #default_desc, #example, #has_option?, name_as_string, #name_for_help

Methods included from GLI::CommandSupport

#arg_name, #arguments, #arguments_description, #arguments_options, #commands, #commands_declaration_order, #context_description, #default_description, #default_value, #desc, #examples, #execute, #flag, #flags, #get_default_command, #has_action?, #long_desc, #names, #nodoc, #switch, #switches, #topmost_ancestor

Methods included from DSL

#arg, #arg_name, #clear_nexts, #command, #command_missing, #default_value, #desc, #flag, #flags_declaration_order, #long_desc, #switch, #switches_declaration_order

Methods inherited from GLI::CommandLineToken

#<=>, #names_and_aliases

Constructor Details

#initialize(app, output = $stdout, error = $stderr) ⇒ Help

Returns a new instance of Help.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/gli/commands/help.rb', line 58

def initialize(app,output=$stdout,error=$stderr)
  super(:names => :help,
        :description => 'Shows a list of commands or help for one command',
        :arguments_name => 'command',
        :long_desc => 'Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function',
        :arguments => [Argument.new(:command_name, [:multiple, :optional])])
  @app = app
  @parent = app
  @sorter = SORTERS[@app.help_sort_type]
  @text_wrapping_class = WRAPPERS[@app.help_text_wrap_type]
  @synopsis_formatter_class = SYNOPSIS_FORMATTERS[@app.synopsis_format_type]

  desc 'List commands one per line, to assist with shell completion'
  switch :c

  action do |global_options,options,arguments|
    if global_options[:version] && !global_options[:help]
      puts "#{@app.exe_name} version #{@app.version_string}"
    else
      show_help(global_options,options,arguments,output,error)
    end
  end
end

Class Method Details

.skips_around=(skips_around) ⇒ Object

Configure help to explicitly skip or not skip the around block when the help command runs. This is here because the creation of the help command is outside of the client programmer’s control



56
# File 'lib/gli/commands/help.rb', line 56

def self.skips_around=(skips_around) ; @@skips_around = skips_around ; end

.skips_post=(skips_post) ⇒ Object

Configure help to explicitly skip or not skip the post block when the help command runs. This is here because the creation of the help command is outside of the client programmer’s control



52
# File 'lib/gli/commands/help.rb', line 52

def self.skips_post=(skips_post)     ; @@skips_post = skips_post     ; end

.skips_pre=(skips_pre) ⇒ Object

Configure help to explicitly skip or not skip the pre block when the help command runs. This is here because the creation of the help command is outside of the client programmer’s control



48
# File 'lib/gli/commands/help.rb', line 48

def self.skips_pre=(skips_pre)       ; @@skips_pre = skips_pre       ; end

Instance Method Details

#skips_aroundObject



84
# File 'lib/gli/commands/help.rb', line 84

def skips_around ; @@skips_around ; end

#skips_postObject



83
# File 'lib/gli/commands/help.rb', line 83

def skips_post   ; @@skips_post   ; end

#skips_preObject



82
# File 'lib/gli/commands/help.rb', line 82

def skips_pre    ; @@skips_pre    ; end