The current argument parsing system for commands enforces a strict order of the types of arguments, which proceeds as:
- Required arguments
- Optional arguments
- Variadic argument or
#[rest] argument
Each type of argument may be absent, but violating this order will result in a macro error. What this issue proposes, however, is to break the strict order for required and optional arguments. This would allow for backtracking when parsing arguments for a command.
For example, for the following command:
#[command]
async fn boogie(ctx: FrameworkContext, msg: &Message, user2: Option<UserId>, user: UserId) -> CommandResult {
// ....
}
no error would originate from the macro. Instead, if just one argument is given, user2 will be None, while user will be populated with the argument. And in the case of two arguments, user2 will be the first argument, and user the second argument.
Order between required/optional arguments and a variadic/#[rest] argument will stay the same and will have to be uphold.