package eu.oschl.console.commands; import eu.oschl.console.Console; import eu.oschl.console.ConsoleColor; import java.util.ArrayList; /** * This command displays a list of all available actions in the console application. * It provides a way for users to see what commands they can use. * * @author Ondřej Schlaichert */ public class Help implements Command { private final ArrayList commands; public Help(ArrayList commands) { this.commands = commands; } @Override public String[] getTriggers() { return new String[]{ "help", "actions", "commands", "list actions", "list commands", }; } @Override public String getDescription() { return "display currently available actions"; } @Override public void execute(String[] args) { if (args.length > 0) { Console.print("This doesn't make any sense.", ConsoleColor.RED); return; } Console.print("available actions:", ConsoleColor.BG_CYAN); for (var command : commands) { if (command == this) { continue; } Console.printLine(); Console.print(" * [" + command.getTriggers()[0] + "]", ConsoleColor.YELLOW); Console.print(" - " + command.getDescription(), ConsoleColor.WHITE); } } }