Add short options into valid tokens

- Add short options as valid tokens in a `CommandModel` so that Lexer
  create tokens with accurate info and doesn't then cascade this issue
  in Ast and Parser.
- Previously with a command `command -a aaa -b bbb` tokenisation resulted
  `COMMAND OPTION ARGUMENT ARGUMENT ARGUMENT` with multiple short options
  while it should have been `COMMAND OPTION ARGUMENT OPTION ARGUMENT`.
- Relates #757
This commit is contained in:
Janne Valkealahti
2023-05-31 17:28:21 +01:00
parent 8cba636fdb
commit c125c46010
5 changed files with 276 additions and 0 deletions

View File

@@ -196,6 +196,9 @@ public class CommandModel {
for (String longName : commandOption.getLongNames()) {
tokens.put("--" + longName, new Token(longName, TokenType.OPTION));
}
for (Character shortName : commandOption.getShortNames()) {
tokens.put("-" + shortName, new Token(shortName.toString(), TokenType.OPTION));
}
});
}
return tokens;