cli: use argpar for top-level args
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 24 Jul 2019 15:56:43 +0000 (11:56 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 2 Aug 2019 15:46:54 +0000 (11:46 -0400)
commit0e497e1c06d5f6bee949b064a14d108aed460cb8
tree29c6e30d36ed4ff2cdf26db8c6ba3e65678e3b5a
parentfac21c8788e860accfc1f3e2b519d355283b1fb5
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.025363 seconds and 4 git commands to generate.