Fix: cli: use correct argument index in subcommand error messages
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Aug 2021 14:06:32 +0000 (10:06 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 27 Aug 2021 01:27:11 +0000 (21:27 -0400)
commita80892bab38643e037d92efae2a9d0de1e006785
treea885234c366f80831292f368be61406bfe16b184
parenta93e984c07724c096b4a0af678703d796e26bf0c
Fix: cli: use correct argument index in subcommand error messages

Because command implementation are not aware that there may have been
arguments before the ones they receive, the argument number in
argument-parsing-related error messages is off:

    $ ./src/cli/babeltrace2 --omit-home-plugin-path convert --foo

    ERROR:    [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2644)
      Command-line error: retcode=1
    CAUSED BY [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c:1423)
      While parsing `convert` command's command-line arguments: While parsing argument #1 (`--foo`): Unknown option `--foo`

The `argument #1` message referring to `--foo` is erroneous, from the
point of view of the user.

Fix that by passing down an offset to apply to argument indices when
error messages are generated.

Change-Id: Ib3254094ed5e3de858f5a69cd1dc02f840a92939
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5929
src/cli/babeltrace2-cfg-cli-args.c
This page took 0.025845 seconds and 4 git commands to generate.