Class HelpCommand
- All Implemented Interfaces:
CommandInterface
-help
command that prints all valid CLI argument commands when executed.
This command is designed to provide users with a list of all available commands
managed by the CommandManager
. It is particularly useful for providing
guidance to users of a CLI application.
Usage
To use this command, include -help
as an argument when running the application.
The command will output a list of valid commands to the console.
Example:
CommandManager commandManager = new CommandManager(); commandManager.executeCommand("-help");
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newHelpCommand
instance without a description.HelpCommand
(String description) Constructs a newHelpCommand
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(CommandManager commandManager) Executes the command using the providedCommandManager
.Returns the description of the command.void
setDescription
(String description) Sets the description of the command.
-
Constructor Details
-
HelpCommand
public HelpCommand()Constructs a newHelpCommand
instance without a description. This command, when executed, prints all valid CLI arguments and their descriptions. managed by theCommandManager
.- See Also:
-
HelpCommand
Constructs a newHelpCommand
instance. This command, when executed, prints all valid CLI arguments and their descriptions. managed by theCommandManager
.- Parameters:
description
- description of what the command does
-
-
Method Details
-
execute
Description copied from interface:CommandInterface
Executes the command using the providedCommandManager
.This method contains the logic for what the command should do when triggered. It is invoked by the
CommandManager
when the associated command key is executed.- Specified by:
execute
in interfaceCommandInterface
- Parameters:
commandManager
- theCommandManager
instance managing the commandExample:
CommandManager commandManager = new CommandManager(); commandManager.executeCommand("-help");
-
getDescription
Description copied from interface:CommandInterface
Returns the description of the command.This description provides a brief explanation of the command's purpose and is typically used in help menus or documentation.
- Specified by:
getDescription
in interfaceCommandInterface
- Returns:
- a
String
describing the commandExample:
HelpCommand helpCommand = new HelpCommand("Displays a list of valid commands"); System.out.println(helpCommand.getDescription()); // Output: "Displays a list of valid commands"
-
setDescription
Description copied from interface:CommandInterface
Sets the description of the command.This description provides a brief explanation of the command's purpose and is typically used in help menus or documentation.
- Specified by:
setDescription
in interfaceCommandInterface
- Parameters:
description
- aString
describing the commandExample:
HelpCommand helpCommand = new HelpCommand("Change Me!"); System.out.println(helpCommand.getDescription()); // Output: "Change Me! helpCommand.setDescription("Displays a list of valid commands"); System.out.println(helpCommand.getDescription()); // Output: "Displays a list of valid commands"
- See Also:
-