2020-04-07 08:32:30 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Cask
|
|
|
|
class Cmd
|
|
|
|
class Help < AbstractCommand
|
2020-08-01 02:30:46 +02:00
|
|
|
def self.max_named
|
|
|
|
1
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.description
|
|
|
|
"Print help for `cask` commands."
|
|
|
|
end
|
|
|
|
|
2020-05-19 19:16:17 +02:00
|
|
|
def run
|
2020-08-01 02:30:46 +02:00
|
|
|
if args.named.empty?
|
|
|
|
puts Cmd.parser.generate_help_text
|
|
|
|
else
|
|
|
|
command_name = args.named.first
|
2020-04-07 08:32:30 +02:00
|
|
|
|
2020-05-19 19:30:46 +02:00
|
|
|
unless command = self.class.commands[command_name]
|
|
|
|
raise "No help information found for command '#{command_name}'."
|
2020-05-19 19:16:17 +02:00
|
|
|
end
|
2020-04-07 08:32:30 +02:00
|
|
|
|
2020-08-01 02:30:46 +02:00
|
|
|
puts command.help
|
2020-05-19 19:16:17 +02:00
|
|
|
end
|
2020-04-07 08:32:30 +02:00
|
|
|
end
|
|
|
|
|
2020-05-19 19:16:17 +02:00
|
|
|
def self.commands
|
|
|
|
Cmd.command_classes.select(&:visible?).map { |klass| [klass.command_name, klass] }.to_h
|
|
|
|
end
|
2020-04-07 08:32:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|