Class: Melon::Commands::Help

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

Instance Attribute Summary

Attributes inherited from Base

#args, #description, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

command_name, #helptext, #initialize, #parse_options!, #parser, #usageargs, #usagebanner, #verify_args

Methods included from Helpers

#blockquote, #error, #expand_dir, #format_command, #recursively_expand, #resolve_symlinks, #wrap_text

Constructor Details

This class inherits a constructor from Melon::Commands::Base

Class Method Details

.descriptionObject



8
9
10
# File 'lib/melon/commands/help.rb', line 8

def self.description
  "Get help with a specific command"
end

Instance Method Details

#run(cli) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/melon/commands/help.rb', line 12

def run(cli)
  if args.empty?
    puts cli.parser
    exit
  end
  help = args.shift
  begin
    puts Commands[help.capitalize].new(args, options).parser
    exit
  rescue NameError => e
    # don't swallow NoMethodErrors
    raise e unless e.instance_of?(NameError)
    error "unrecognized command: #{help}"
  end
end