Vampire / command-framework

A generic CDI-based command framework
Apache License 2.0
13 stars 5 forks source link

added support for multiple @Usage annotations #1

Closed cap5lut closed 2 years ago

Vampire commented 4 years ago

I'm not sure I like the idea of combining the usage strings in Command#getUsage. It feels wrong, because neither Command#getUsage, nor @Usage are the ones that define how a usage string has to look like, the format is arbitrary. If you use the ParameterParser, then it has to follow that syntax defined there and only then it makes sense to combine the individual usages that way.

Vampire commented 4 years ago

Maybe it is better to return a List<String> from Command#getUsage() and then in BaseParameterParser#parse assemble the separate usages together as that is where the semantic and syntax are defined. And in TypedParameterParser#parse you would search for the first usage string where the invalid parameter type is used and use that in the error message. What do you think?

Vampire commented 4 years ago

Hm, maybe even better a second attribute for @Usage called description where you can add a descirption for the usage variant and then return a Map<String, Optional<String>>, then a help command can show usage variants with individual descriptions if available.