show missing argument error only for last flag

closes #6483
This commit is contained in:
Johannes Altmanninger
2020-01-08 14:59:26 +01:00
parent 0e707b88f0
commit fdf398e435
5 changed files with 8 additions and 6 deletions

View File

@@ -550,7 +550,8 @@ static int argparse_parse_flags(parser_t &parser, argparse_cmd_opts_t &opts,
wgetopter_t w;
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, &long_idx)) != -1) {
if (opt == ':') {
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, argv[w.woptind - 1]);
const wchar_t *arg = argv[w.woptind - 1];
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, arg + std::wcslen(arg) - 1);
return STATUS_INVALID_ARGS;
} else if (opt == '?') {
// It's not a recognized flag. See if it's an implicit int flag.