author | Olivier Brunel
<jjk@jjacky.com> 2023-04-05 08:55:22 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-05-20 18:06:35 UTC |
parent | 5c24e80556a77985292566a4409304a5e872b0c0 |
src/liblimb/loadopt.h/loadopt.c | +8 | -0 |
diff --git a/src/liblimb/loadopt.h/loadopt.c b/src/liblimb/loadopt.h/loadopt.c index c18d97d..bcd4b21 100644 --- a/src/liblimb/loadopt.h/loadopt.c +++ b/src/liblimb/loadopt.h/loadopt.c @@ -41,6 +41,14 @@ parseopt_warn(int c, const char **argv, const struct option *options, case ENOENT: if (!strncmp(argv[ctx->cur], "--", 2)) { warn("unknown option: ", argv[ctx->cur]); + /* was there a partial match? */ + if (ctx->idx >= 0) { + const char *s = argv[ctx->cur] + ctx->off; + size_t l = byte_chr(s, strlen(s), '='); + list_matches_full(err_putmsg, OLVL_NORMAL, "did you mean ", + "--", " or ", " ?", s, l, ctx->idx, options, + offsetof(struct option, longopt), sizeof(*options)); + } } else { char buf[3] = { '-', argv[ctx->cur][ctx->off], 0 }; warn("unknown option: ", buf);