|
3 | 3 | import seedu.clinic.model.Model; |
4 | 4 |
|
5 | 5 | /** |
6 | | - * Format full help instructions for every command for display. |
| 6 | + * Format full help instructions for respective help command to display. |
7 | 7 | */ |
8 | 8 | public class HelpCommand extends Command { |
9 | 9 |
|
10 | 10 | public static final String COMMAND_WORD = "help"; |
11 | 11 |
|
12 | | - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n" |
13 | | - + "Example: " + COMMAND_WORD; |
| 12 | + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows all command with" |
| 13 | + + " respective utility description\n" |
| 14 | + + "Example: " + COMMAND_WORD + "\n\nSpecific commands with respective input samples " |
| 15 | + + "can be shown as well \n" + "Example: help find"; |
| 16 | + public static final String MESSAGE_TOO_MANY_ARGUMENTS = "You can only enter one command at a time\n\n" |
| 17 | + + MESSAGE_USAGE; |
| 18 | + public static final String MESSAGE_WRONG_ARGUMENT = "You can only enter command from one of the " |
| 19 | + + "following keywords: add, clear, delete, exit, find, view, update"; |
14 | 20 |
|
15 | 21 | public static final String SHOWING_HELP_MESSAGE = "Opened help window."; |
| 22 | + public static final String[] ALLOWED_ARGUMENTS = new String[]{ |
| 23 | + "add", "clear", "delete", "exit", "find", "list", "view", "update"}; |
| 24 | + |
| 25 | + public static final String HELP_MESSAGE_FOR_COMMAND_FORMAT = "How to interpret command format?\n" |
| 26 | + + "Words in UPPER_CASE are the parameters to be supplied by the user." |
| 27 | + + " Items in square brackets are optional. Items with ... after them can be used multiple times." |
| 28 | + + " Parameters can be in any order."; |
| 29 | + |
| 30 | + public static final String HELP_MESSAGE_FOR_USER_GUIDE = "Press F1 to copy the URL to view User Guide" |
| 31 | + + " on our website for more details on each command sample"; |
| 32 | + |
| 33 | + private final String commandArgument; |
| 34 | + |
| 35 | + /** |
| 36 | + * Constructs a new HelpCommand object. |
| 37 | + * |
| 38 | + * @param commandArgument takes in the command argument (if any) specified for help command. |
| 39 | + */ |
| 40 | + public HelpCommand(String commandArgument) { |
| 41 | + this.commandArgument = commandArgument; |
| 42 | + } |
16 | 43 |
|
17 | 44 | @Override |
18 | 45 | public CommandResult execute(Model model) { |
19 | | - return new CommandResult(SHOWING_HELP_MESSAGE, true, false); |
| 46 | + String helpMessage = "test"; |
| 47 | + switch(commandArgument) { |
| 48 | + case "add": |
| 49 | + helpMessage = generateHelpAddMessage(); |
| 50 | + break; |
| 51 | + case "clear": |
| 52 | + helpMessage = generateHelpClearMessage(); |
| 53 | + break; |
| 54 | + case "delete": |
| 55 | + helpMessage = generateHelpDeleteMessage(); |
| 56 | + break; |
| 57 | + case "exit": |
| 58 | + helpMessage = generateHelpExitMessage(); |
| 59 | + break; |
| 60 | + case "find": |
| 61 | + helpMessage = generateHelpFindMessage(); |
| 62 | + break; |
| 63 | + case "list": |
| 64 | + helpMessage = generateHelpListMessage(); |
| 65 | + break; |
| 66 | + case "view": |
| 67 | + helpMessage = generateHelpViewMessage(); |
| 68 | + break; |
| 69 | + case "update": |
| 70 | + helpMessage = generateHelpUpdateMessage(); |
| 71 | + break; |
| 72 | + default: |
| 73 | + helpMessage = generateHelpGenericMessage(); |
| 74 | + } |
| 75 | + |
| 76 | + return new CommandResult(helpMessage, false, false); |
| 77 | + } |
| 78 | + |
| 79 | + private String generateHelpGenericMessage() { |
| 80 | + String aboutHelpCommand = "You can view more of each command using \nhelp COMMAND.\n\n" |
| 81 | + + "Sample Command:\nhelp find\n\nShows what find command does, command format and" |
| 82 | + + " sample command(s) to follow.\n\n" |
| 83 | + + "If you wish to learn more about sample commands found under" |
| 84 | + + " each command, feel free to copy our website User Guide URL," |
| 85 | + + " which can be found by pressing F1."; |
| 86 | + |
| 87 | + String aboutAddCommand = "add\nYou can add warehouse, supplier or product to a supplier using the add" |
| 88 | + + " command"; |
| 89 | + String aboutClearCommand = "clear\nYou can clear all entries (suppliers and warehouses)" |
| 90 | + + " in CLI-nic using clear command."; |
| 91 | + String aboutDeleteCommand = "delete\nYou can delete warehouse or supplier that are no longer" |
| 92 | + + " needed by using the delete command."; |
| 93 | + String aboutExitCommand = "exit\nYou can exit the application using the exit command."; |
| 94 | + String aboutFindCommand = "find\nYou can find suppliers or warehouses that sells the products using" |
| 95 | + + " the find command."; |
| 96 | + String aboutListCommand = "list\nYou can list all suppliers and warehouses by using list command."; |
| 97 | + String aboutViewCommand = "view\nYou can view a specific warehouse or supplier using" |
| 98 | + + " the view command."; |
| 99 | + String aboutUpdateCommand = "update\nYou can update stock of a product in the warehouse by" |
| 100 | + + " using the update command"; |
| 101 | + |
| 102 | + String finalGenericHelpMessage = aboutHelpCommand + "\n\n" + aboutAddCommand + "\n\n" |
| 103 | + + aboutClearCommand + "\n\n" + aboutDeleteCommand + "\n\n" + aboutExitCommand |
| 104 | + + "\n\n" + aboutFindCommand + "\n\n" + aboutListCommand + "\n\n" + aboutViewCommand |
| 105 | + + "\n\n" + aboutUpdateCommand; |
| 106 | + return finalGenericHelpMessage; |
| 107 | + } |
| 108 | + |
| 109 | + private String generateHelpAddMessage() { |
| 110 | + String generalDescriptionOfAdd = "There are three types of add command to add warehouse," |
| 111 | + + " add supplier or add a product to a supplier."; |
| 112 | + |
| 113 | + String addWarehouse = "Add Warehouse \nAdds warehouse to the CLI-nic application."; |
| 114 | + String addWarehouseCommandFormat = "Command format: \nadd w/WAREHOUSE_NAME p/CONTACT_NUMBER" |
| 115 | + + " addr/ADDRESS" + " [r/WAREHOUSE_NOTE]"; |
| 116 | + String addWarehouseSampleCommand = "Sample Command: \nadd w/warehouseA p/00000000" |
| 117 | + + " addr/John street, block 123, #01-01 r/First warehouse"; |
| 118 | + String finalAddWarehouse = addWarehouse + "\n\n" + addWarehouseCommandFormat + "\n\n" |
| 119 | + + addWarehouseSampleCommand; |
| 120 | + |
| 121 | + String addSupplier = "Add Supplier \nAdds a supplier to the CLI-nic application."; |
| 122 | + String addSupplierCommandFormat = "Command format: \nadd s/SUPPLIER_NAME pd/PRODUCT_NAME [t/TAG...]"; |
| 123 | + String addSupplierSampleCommand = "Sample Command: \nadd s/Philips Pharmaceutical p/00000000" |
| 124 | + + " e/[email protected] r/largest contractor"; |
| 125 | + String finalAddSupplier = addSupplier + "\n\n" + addSupplierCommandFormat + "\n\n" |
| 126 | + + addSupplierSampleCommand; |
| 127 | + |
| 128 | + String addProductToSupplier = "Add Product to Supplier \nAdds product information to a supplier;" |
| 129 | + + " associates a particular" + " product with the supplier in the CLI-nic application."; |
| 130 | + String addProductToSupplierCommandFormat = "Command format: \nadd s/SUPPLIER_NAME pd/PRODUCT_NAME" |
| 131 | + + " [t/TAG...]"; |
| 132 | + String addProductToSupplierSampleCommand = "Sample Command: \n" |
| 133 | + + "add s/SupplierA pd/PANADOL SUSP t/FEVER"; |
| 134 | + String finalAddProductToSupplier = addProductToSupplier + "\n\n" + addProductToSupplierCommandFormat |
| 135 | + + "\n\n" + addProductToSupplierSampleCommand; |
| 136 | + |
| 137 | + String addHelpMessage = HELP_MESSAGE_FOR_COMMAND_FORMAT + "\n\n" + generalDescriptionOfAdd + "\n\n" |
| 138 | + + finalAddWarehouse + "\n\n" + finalAddSupplier + "\n\n" + finalAddProductToSupplier |
| 139 | + + "\n\n" + HELP_MESSAGE_FOR_USER_GUIDE; |
| 140 | + |
| 141 | + return addHelpMessage; |
| 142 | + } |
| 143 | + |
| 144 | + private String generateHelpClearMessage() { |
| 145 | + return "Clear\n\nClear all entries (suppliers and warehouses) in CLI-nic.\n\nSample Command: \nclear"; |
| 146 | + } |
| 147 | + |
| 148 | + private String generateHelpDeleteMessage() { |
| 149 | + String deleteSupplierOrWarehouse = "Delete\nDelete entries of warehouses or suppliers that are" |
| 150 | + + " not needed anymore."; |
| 151 | + String deleteSupplierOrWarehouseCommandFormat = "Command format: \ndelete TYPE INDEX"; |
| 152 | + String deleteSupplierOrWarehouseSampleCommand = "Sample Command: \ndelete warehouse 1 \n" |
| 153 | + + "delete supplier 12"; |
| 154 | + |
| 155 | + String deleteHelpMessage = HELP_MESSAGE_FOR_COMMAND_FORMAT + "\n\n" + deleteSupplierOrWarehouse |
| 156 | + + "\n\n" + deleteSupplierOrWarehouseCommandFormat + "\n\n" |
| 157 | + + deleteSupplierOrWarehouseSampleCommand + "\n\n" + HELP_MESSAGE_FOR_USER_GUIDE; |
| 158 | + return deleteHelpMessage; |
| 159 | + } |
| 160 | + |
| 161 | + private String generateHelpExitMessage() { |
| 162 | + return "Exit\n\nExits the program.\n\nSample Command:\nexit"; |
| 163 | + } |
| 164 | + |
| 165 | + private String generateHelpFindMessage() { |
| 166 | + String findProductsInSupplierOrWarehouse = "Find\nFinds all suppliers or warehouses managed by the manager" |
| 167 | + + " that sells the relevant medical products."; |
| 168 | + String findProductsInSupplierOrWarehouseCommandFormat = "Command format: \nfind TYPE KEYWORD...\n" |
| 169 | + + "KEYWORD specified is case-insensitive.\n" |
| 170 | + + "The TYPE specified should be one of these values: warehouse / supplier."; |
| 171 | + String findProductsInSupplierOrWarehouseSampleCommand = "Sample Command: \n" |
| 172 | + + "find warehouse PANADOL SUSP \nfind supplier masks"; |
| 173 | + String findHelpMessage = HELP_MESSAGE_FOR_COMMAND_FORMAT + "\n\n" |
| 174 | + + findProductsInSupplierOrWarehouse + "\n\n" |
| 175 | + + findProductsInSupplierOrWarehouseCommandFormat + "\n\n" |
| 176 | + + findProductsInSupplierOrWarehouseSampleCommand + "\n\n" + HELP_MESSAGE_FOR_USER_GUIDE; |
| 177 | + return findHelpMessage; |
| 178 | + } |
| 179 | + |
| 180 | + private String generateHelpListMessage() { |
| 181 | + return "List\n\nLists all suppliers and warehouses.\n\nSample Command:\nlist"; |
| 182 | + } |
| 183 | + |
| 184 | + private String generateHelpViewMessage() { |
| 185 | + String viewWarehouseOrSupplier = "View\nShows a particular supplier/warehouse with their relevant" |
| 186 | + + " information e.g. products associated with the supplier/warehouse, address etc."; |
| 187 | + String viewWarehouseOrSupplierCommandFormat = "Command format: \nview TYPE NAME\n" |
| 188 | + + "The TYPE specified should be one of these values: supplier or warehouse.\n" |
| 189 | + + "The supplier/warehouse NAME specified is case-insensitive."; |
| 190 | + String viewWarehouseOrSupplierSampleCommand = "Sample Command: \nview supplier supplierA" |
| 191 | + + "\nview warehouse warehouseB"; |
| 192 | + String viewCommandHelpMessage = HELP_MESSAGE_FOR_COMMAND_FORMAT + "\n\n" |
| 193 | + + viewWarehouseOrSupplier + "\n\n" |
| 194 | + + viewWarehouseOrSupplierCommandFormat + "\n\n" |
| 195 | + + viewWarehouseOrSupplierSampleCommand + "\n\n" + HELP_MESSAGE_FOR_USER_GUIDE; |
| 196 | + return viewCommandHelpMessage; |
| 197 | + } |
| 198 | + |
| 199 | + private String generateHelpUpdateMessage() { |
| 200 | + String updateWarehouseProduct = "Update\nIf the product does not exist for that warehouse," |
| 201 | + + " it will associate the new product with the warehouse and the input quantity." |
| 202 | + + " Otherwise, it will update the stock of the existing product with the new quantity."; |
| 203 | + String updateWarehouseProductCommandFormat = "Command format: \n" |
| 204 | + + "update w/WAREHOUSE_NAME pd/PRODUCT_NAME q/QUANTITY"; |
| 205 | + String updateWarehouseProductSampleCommand = "Sample Command: \n" |
| 206 | + + "update w/WarehouseA pd/Panadol q/10"; |
| 207 | + String updateCommandHelpMessage = HELP_MESSAGE_FOR_COMMAND_FORMAT + "\n\n" |
| 208 | + + updateWarehouseProduct + "\n\n" |
| 209 | + + updateWarehouseProductCommandFormat + "\n\n" |
| 210 | + + updateWarehouseProductSampleCommand + "\n\n" + HELP_MESSAGE_FOR_USER_GUIDE; |
| 211 | + return updateCommandHelpMessage; |
| 212 | + } |
| 213 | + |
| 214 | + @Override |
| 215 | + public boolean equals(Object other) { |
| 216 | + return other == this // short circuit if same object |
| 217 | + || (other instanceof HelpCommand // instanceof handles nulls |
| 218 | + && commandArgument.equals(((HelpCommand) other).commandArgument)); // state check |
20 | 219 | } |
21 | 220 | } |
0 commit comments