forked from nus-cs2113-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
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
jinzihan2002
merged 7 commits into
AY2425S1-CS2113-W13-4:master
from
TrungBui32:helpCommand
Nov 11, 2024
Merged
Help command #216
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
48b9968
Add HELP_MESSAGE
TrungBui32 cabc39e
Add helpcommand into Parser
TrungBui32 dd2ec33
Create HelpCommand
TrungBui32 6cc187e
Fix checkStyle
TrungBui32 455f63f
Fix checkStyle second time
TrungBui32 f17e374
Add newline at the end
TrungBui32 ecf0730
Remove redundant break lines
TrungBui32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the break line can be removed from the HELP_MESSAGE string?
Since it will be passed into ui.displayResult(), which will print break lines at the start and end again.