require "mothership/help/printer" class Mothership class << self # add command to help group def group(*names) options = if names.last.is_a? Hash names.pop else {} end Mothership::Help.add_to_group(@command, names, options) end end def default_action invoke :help end def unknown_command(name) $stderr.print "Unknown command '#{name.to_s.gsub("_", "-")}'. " $stderr.puts "See 'help' for available commands." exit_status 1 end desc "Help!" input :command, :argument => :optional input :all, :type => :boolean def help # custom header puts "\x1B[1m\x1B[33m===========================================================\x1B[00m" puts "\x1B[1m\x1B[33m* Welcome Cloulu Platform\x1B[00m" puts "\x1B[1m\x1B[33m*\x1B[00m" puts "\x1B[1m\x1B[33m* @author clouluteam \x1B[00m" puts "\x1B[1m\x1B[33m* @homepage https://cloulu.com, http://blog.cloulu.com\x1B[00m" puts "\x1B[1m\x1B[33m============================================================\x1B[00m" puts if name = input[:command] if cmd = @@commands[name.gsub("-", "_").to_sym] Mothership::Help.command_help(cmd) else unknown_command(name) end elsif Help.has_groups? Mothership::Help.print_help_groups(@@global, input[:all]) else Mothership::Help.basic_help(@@commands, @@global) end end end