se-edu / addressbook-level3

:ab::three: Address Book sample application (Level 3)
https://se-education.org/addressbook-level3
MIT License
28 stars 415 forks source link

Give a warning when a parameter is repeated in a user command #162

Closed damithc closed 1 year ago

damithc commented 1 year ago

Currently, if the same parameter is repeated multiple times in a command, all except the last occurrence are ignored silently.

e.g., add n/John Doe p/98765432 e/johnd@example.com a/John street p/112345678 (112345678 is taken as the phone number; p/98765432 is ignored)

This allows the user to correct a typo in a previous parameter by quickly retyping it in the command, rather than going back and editing the previous incorrect version of it.

However, this can cause certain user errors to go unnoticed e.g., if the user used a wrong parameter prefix, resulting in the same prefix appearing multiple times in the command.

Suggestion: Give a friendly warning to the user when a parameter is being ignored. Alternative: Treat repeated parameters as an error.