Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help command #216

Merged
merged 7 commits into from
Nov 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create HelpCommand
TrungBui32 committed Nov 11, 2024
commit dd2ec332db6853aa00f78c45c0d8138cee0f2c8b
52 changes: 52 additions & 0 deletions src/main/java/tutorlink/command/HelpCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tutorlink.command;

import tutorlink.appstate.AppState;
import tutorlink.commons.Commons;
import tutorlink.exceptions.TutorLinkException;
import tutorlink.result.CommandResult;

import java.util.HashMap;

/**
* Represents a help command that displays usage information.
* This command shows a list of all available commands and their proper usage.
* This command is triggered using the "help" keyword.
*/
public class HelpCommand extends Command {
/**
* Command word that triggers this command
*/
public static final String COMMAND_WORD = "help";

/**
* Creates a new HelpCommand instance.
*/
public HelpCommand() {
}

/**
* Executes the help command.
* Returns a command result containing the help message that lists
* all available commands and their usage.
*
* @param state The current state of the application
* @param arguments Command arguments (not used for help command)
* @return CommandResult containing the help message
* @throws TutorLinkException if there's an error executing the command
*/
@Override
public CommandResult execute(AppState state, HashMap<String, String> arguments) throws TutorLinkException {
return new CommandResult(Commons.HELP_MESSAGE);
}

/**
* Gets the argument prefixes that this command accepts.
* Help command doesn't accept any arguments.
*
* @return null since this command takes no arguments
*/
@Override
public String[] getArgumentPrefixes() {
return null;
}
}