Class: Kut::HelpCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/kut/commands/help-cmd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHelpCommand

Returns a new instance of HelpCommand.



8
9
10
11
# File 'lib/kut/commands/help-cmd.rb', line 8

def initialize
  @name = 'help'
  @help_banner = 'Help for information on a specific command.'
end

Instance Attribute Details

#help_bannerObject (readonly)

Returns the value of attribute help_banner.



6
7
8
# File 'lib/kut/commands/help-cmd.rb', line 6

def help_banner
  @help_banner
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/kut/commands/help-cmd.rb', line 5

def name
  @name
end

Instance Method Details

#help(args) ⇒ Object



13
14
15
# File 'lib/kut/commands/help-cmd.rb', line 13

def help(args)
  @help_banner
end

#run(args) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/kut/commands/help-cmd.rb', line 24

def run(args)
  Kut.application.show_help() unless args
  Kut.application.show_help() if args.size() == 0
  help_args = args.dup()
  help_args.delete_at(0)
  show_cmd_help(args[0], help_args)
end

#show_cmd_help(cmd_name, args) ⇒ Object



17
18
19
20
21
22
# File 'lib/kut/commands/help-cmd.rb', line 17

def show_cmd_help(cmd_name, args)
  cmd = Kut.application.command_by_name(cmd_name)
  puts cmd.help(args) if cmd
  puts "Help for command #{cmd_name} not found." unless cmd
  exit
end