cli: add pluralization to err msg, if required number of args is not met (#20971)

This commit is contained in:
Turiiya 2024-03-08 01:57:58 +07:00 committed by GitHub
parent 790ea2f1bd
commit db252d043e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -230,7 +230,8 @@ fn (mut cmd Command) parse_commands() {
// if no further command was found, execute current command
if cmd.required_args > 0 {
if cmd.required_args > cmd.args.len {
eprintln_exit('Command `${cmd.name}` needs at least ${cmd.required_args} arguments')
descriptor := if cmd.required_args == 1 { 'argument' } else { 'arguments' }
eprintln_exit('Command `${cmd.name}` needs at least ${cmd.required_args} ${descriptor}')
}
}
cmd.check_required_flags()