Skip to content

Commit

Permalink
Merge 4b98f2b into 843ad53
Browse files Browse the repository at this point in the history
  • Loading branch information
Wingedevil committed Oct 30, 2019
2 parents 843ad53 + 4b98f2b commit 03e734c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Format: `clear`
=== Setting shorthand commands: `alias`

Set an alias for a command to do shorthand. +
Format: `alias l/[SHORTHAND] v/[COMMAND]`
Format: `alias l/SHORTHAND v/COMMAND`

Examples:

Expand All @@ -176,21 +176,21 @@ Typing `h` now works equivalently as `help`.
=== Deleting shorthand commands: `unalias`

Delete a existing alias. +
Format: `unalias [SHORTHAND]`
Format: `unalias SHORTHAND`

Examples:

* `unalias ls` +
Typing `ls` is no longer equivalent to `list`.

=== Showing all existing aliases: `showalias`
=== Showing all existing aliases: `aliaslist`

Show all existing aliases. +
Format: `showalias`
Format: `aliaslist`

Examples:

* `showalias` +
* `aliaslist` +
Shows all the existing aliases.

=== Clearing all entries : `clear`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package seedu.address.logic.commands;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;

public class AliasCommandIntegrationTest {
private Model model;

@BeforeEach
public void setUp() {
model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
}

@Test
public void execute_newAlias_success() {
String alias = "TEST ALIAS";
String aliasTo = "help";

Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
expectedModel.addAlias(alias, aliasTo);

assertCommandSuccess(new AliasCommand(alias, aliasTo), model,
String.format(AliasCommand.MESSAGE_SUCCESS, alias, aliasTo), expectedModel);
}

@Test
public void execute_overridingExistingCommand_throwsCommandException() {
String alias = "help";
String aliasTo = "exit";
assertCommandFailure(new AliasCommand(alias, aliasTo), model, AliasCommand.MESSAGE_ALIAS_FAILED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package seedu.address.logic.commands;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;

import org.junit.jupiter.api.Test;

import seedu.address.model.Model;
import seedu.address.model.ModelManager;

public class AliasListCommandTest {
private Model model = new ModelManager();
private Model expectedModel = new ModelManager();


@Test
public void execute_aliasList_success() {
String expectedStringForDefaultAliasTable = "a ⟶ add\n"
+ "<meta http-equiv=\"refresh\" content=\"0; URL='http://example.org'\" /> ⟶ aliaslist\n"
+ "e ⟶ exit\n"
+ "h ⟶ help\n";
CommandResult expectedCommandResult = new CommandResult(expectedStringForDefaultAliasTable,
false, false, false, false, false, false, false, true);
System.out.println((new AliasListCommand().execute(model).getFeedbackToUser()));
assertCommandSuccess(new AliasListCommand(), model, expectedCommandResult, expectedModel);
}
}

0 comments on commit 03e734c

Please sign in to comment.