Class: Hotdog::Commands::Help

Inherits:
BaseCommand show all
Defined in:
lib/hotdog/commands/help.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#application, #logger, #options, #persistent_db_path

Instance Method Summary collapse

Methods inherited from BaseCommand

#define_options, #execute, #fixed_string?, #initialize, #parse_options, #reload

Constructor Details

This class inherits a constructor from Hotdog::Commands::BaseCommand

Instance Method Details

#run(args = [], options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hotdog/commands/help.rb', line 8

def run(args=[], options={})
  commands = command_files.map { |file| File.basename(file, ".rb") }.sort.uniq
  if "commands" == args.first
    STDOUT.puts("hotdog commands are:")
    commands.each do |command|
      STDOUT.puts("- #{command}")
    end
  else
    ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
    if commands.include?(args.first)
      exit(system(ruby, $0, args.first, "--help") ? 0 : 1)
    else
      exit(system(ruby, $0, "--help") ? 0 : 1)
    end
  end
end