Class: GitPusshuTen::Commands::Help

Inherits:
Base
  • Object
show all
Defined in:
lib/gitpusshuten/commands/help.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#cli, #command, #configuration, #environment, #hooks, #perform_hooks

Instance Method Summary collapse

Methods inherited from Base

#c, #command_object, description, #e, #error, example, #g, #git, #help, #local, long_description, #message, #perform!, #perform_hooks!, #post_perform!, #pre_perform!, #prompt_for_root_password!, #prompt_for_user_password!, #r, #requires_user_existence!, #silent, #standard, usage, #validate!, #warning, #y, #yes?

Constructor Details

#initialize(*objects) ⇒ Help

Returns a new instance of Help.



13
14
15
16
17
# File 'lib/gitpusshuten/commands/help.rb', line 13

def initialize(*objects)
  super
  
  @command_name = cli.arguments.shift
end

Instance Attribute Details

#command_nameObject

Returns the value of attribute command_name.



11
12
13
# File 'lib/gitpusshuten/commands/help.rb', line 11

def command_name
  @command_name
end

Instance Method Details

#perform_!Object

Displays the help screen if no arguments are specified Displays the help screen for a particular command if an argument is specified



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitpusshuten/commands/help.rb', line 22

def perform_!
  if command_name.nil?
    command_object.display_commands
  else
    if command_object.available_commands.include?(command_name)
      command_object.display_usage(command_name)
    else
      error "Command <#{r(command_name)}> not found."
    end
  end
end