cli: use argpar for top-level args
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 24 Jul 2019 15:56:43 +0000 (11:56 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Aug 2019 18:05:20 +0000 (14:05 -0400)
commit091cc3eb4a566c191327aad16c14d9526d752a40
tree217fdda476a666f1678ba38fcf028f15bdf9461f
parent7263c7a9769e08782bcb7d80f6cc32d2b1b86e17
cli: use argpar for top-level args

This patch replaces the hand-made parsing of the top-level arguments
with something based on the internal argpar library.

No functional changes expected from the point of view of the user.

One internal difference is that previously, the argc/argv passed to
sub-commands included an argv[0] that was ignored by popt.  In the
subsequent patches, we replace popt with argpar, and argpar doesn't want
an argv[0] containing the name of the program.  So instead of passing an
unnecessary argv[0], I have made it such that the argc/argv the
top-level passes to subcommands only represent the actual arguments.  So
for example, with:

    babeltrace2 convert -c src.ctf.fs

the bt_config_convert_from_args function used to receive this as argv:

    ["convert", "-c", "src.ctf.fs"]

With

    babeltrace2 --debug -c src.ctf.fs

it used to receive

    ["--debug", "-c", "src.ctf.fs"]

With this patch, it will only receive `["-c", "src.ctf.fs"]`.  So
functions bt_config_*_from_args are updated to cope with this
change.  In particular, I passed the POPT_CONTEXT_KEEP_FIRST flag to
poptGetContext.  But in practice, they will all disappear anyway, in
favor of argpar.

Change-Id: I9f1210f1c338c7eb39e228e20218c83e46961ee4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1789
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/Makefile.am
src/cli/babeltrace2-cfg-cli-args.c
This page took 0.026579 seconds and 4 git commands to generate.