brackeys-bot
brackeys-bot copied to clipboard
[FEATURE] Flag functionality for commands
Why do you want this feature? What is the problem? As adressed in previous issues, it is difficult to infer command usage from their arguments. To improve this, argument flags should be introduced.
Describe the solution you'd like
Runtime-wise, the user would be able to enter: []command -a --argument
, where -a
and --argument
are the respective short- and long-forms of the arguments.
Code-wise, the developer should be able to declare flag enum
s, which can then be used as the command parameter type. To allow type reading, a generic type reader needs to be introduced. The fields inside the enum should be decorated with an attribute that holds the short- and long-forms of that flag.
[Flags]
public enum FlagExample
{
None = 0,
[ArgFlag("a", "add")]
Add = 1,
[ArgFlag("r", "remove")]
Remove = 2
}
Additional notes
- Not every command needs to be able to invoked using flags. It remains optional for the developer of the individual command.
- Flags can be passed in random order.