From 8c73413201a720dd24451b468155069f954dfd35 Mon Sep 17 00:00:00 2001 From: Yaroslav de la Peña Smirnov Date: Sat, 13 Sep 2025 01:30:01 +0300 Subject: cli: minor bug fixes and improvments --- cli/cli-opts.h | 2 +- cli/cli.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/cli-opts.h b/cli/cli-opts.h index 4a94bcc..2266230 100644 --- a/cli/cli-opts.h +++ b/cli/cli-opts.h @@ -71,7 +71,7 @@ int cli_opt_data_size_set(struct cli_opt *self, const char *val) invalid: fprintf(stderr, "invalid value \"%s\", expected a number optionally followed " - "by a multiplicative suffix (K, M, G, T).", + "by a multiplicative suffix (K, M, G, T).\n", val); return CLI_RC_ERR; } diff --git a/cli/cli.h b/cli/cli.h index 72b89c5..00848e8 100644 --- a/cli/cli.h +++ b/cli/cli.h @@ -431,8 +431,11 @@ static int parse_options(struct cli_ctx *ctx) return CLI_RC_OK; if (key[1] == '-') { /* Everything after '--' are non-option arguments */ - if (key[2] == '\0') + if (key[2] == '\0') { + ctx->argc--; + ctx->argv++; return CLI_RC_OK; + } int rc = parse_long(ctx); if (rc != CLI_RC_OK) @@ -520,7 +523,7 @@ static int cli_run(struct cli *const cli, int argc, char *argv[]) ctx.argv++; rc = cli_cmd_run(cli, cmd, &ctx); - goto out; + return rc; } } rc = CLI_RC_BAD_ARGS; -- cgit v1.2.3