summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Philippe Proulx [Sat, 29 May 2021 02:49:54 +0000 (22:49 -0400)]
tests/test_argpar.c: fix coding style
Add missing `const`, clarify comments, harmonize test messages.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie0f4ca02786b1cc1167c0f2aa4be86d7a9e1a45b
Philippe Proulx [Sat, 29 May 2021 02:08:54 +0000 (22:08 -0400)]
argpar.h: `BABELTRACE_ARGPAR_H` -> `ARGPAR_ARGPAR_H`
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id85bcf2f4910af8f83a48333f0f04dd62970951b
Philippe Proulx [Fri, 28 May 2021 19:21:48 +0000 (15:21 -0400)]
argpar/argpar.{c,h}: fix coding style
Add missing `const`, use uppercase macro names, fix comments, fix names
of local functions.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I18c7a2b1d5572f6b696c72f0cfa12b68c1c5f949
Simon Marchi [Sat, 10 Apr 2021 13:51:38 +0000 (09:51 -0400)]
Add iterator-style API
The current API of argpar does not give the user control on when to stop
parsing the arguments. It either stops at the end of the argument list
or at the first unknown option, if using `fail_on_unknown_opt`.
To make it more convenient to implement "multi-level" command line
interfaces, add an iterator-style API where the user repeatedly calls a
function to get the next item.
By "multi-level" CLI, I mean something like git, where the top-level
command and a subcommand have their own set of options.
$ top-level --hello there sub-command --hello
For most cases, we could probably work something out by using the
`fail_on_unknown_opt` option combined with the
`argpar_item_non_opt::orig_index` field. Even if the parsing of the
top-level command goes too far, we can resume the parsing at the index
of the sub-command + 1. But the example above shows a corner case where
top-level's `--hello` option takes an argument but sub-command's
`--hello` doesn't. I don't think we could handle this today.
In any case, I think that it's simpler in the end to give a bit more
control to the user and let her get items one by one. I think it
results in code that is easier to follow.
Using the proposed API, the user starts by creating an argpar_iter
object using argpar_iter_create. It then calls argpar_iter_parse_next
as much as needed to get one argpar_item at a time. The returned
argpar_items must be freed with argpar_item_destroy. In the end, the
argpar_iter must be freed with argpar_iter_destroy.
Testing-wise, I adapted the existing tests to be executed with both
APIs, so the coverage should be pretty good.
Change-Id: I82685672977fbfa96f96bcc678a3e05c6adab76c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Fri, 21 May 2021 03:23:21 +0000 (23:23 -0400)]
Import warning flags and tap from Babeltrace
Since we are going to use this code in Babeltrace, lttng-tools, and
perhaps other projects, I think it would be useful to use warning flags
at least as strict here as we do in these other projects, so we don't
have bad surprises when importing the code there.
Start by importing the warning flag checking system from Babeltrace, and
the list of warning flags used there.
Import the tap code as well, since the current tap code would generate
some errors with the new warning flags.
Change-Id: I86bf5a18bcbce35b887d3ef3285d5566b3f7c69f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Sat, 10 Apr 2021 13:44:03 +0000 (09:44 -0400)]
Use SPDX-style license header
This is copied from the lttng-tools repo. In that repo, the comment is
above the header include guard, so I put it at the same place here.
Change-Id: If71e76e78fe2d4347b5ef24d37126ce7f33fb0a1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Fri, 9 Apr 2021 16:39:19 +0000 (12:39 -0400)]
Fix: Error out when passing an argument to long option that takes no argument
If the user defines a long option `--foo` and passes `--foo=arg`, the
current behavior is that the option foo is recognized and the argument
is ignored. Change that to be an error.
It is currently not possible to pass arguments to short options using an
equal sign, so this doesn't apply to short options.
Change-Id: I4b0c50398161aebc81789fdb3fce19a80a5f6646
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Sun, 15 Mar 2020 19:36:10 +0000 (15:36 -0400)]
Add format attributes to functions with format strings
Compiling with -Wsuggest-attribute=format shows that these functions
could use a format attribute, which helps the compiler validate format
strings. This patch adds them.
Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Change-Id: I2884d13b08d9ea67680289e59fb40ebdfecdc3d4
Simon Marchi [Fri, 6 Dec 2019 19:23:29 +0000 (14:23 -0500)]
Add missing va_end in argpar_vasprintf
args2 is currently leaked, we need to call va_end on it.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Thu, 5 Dec 2019 18:57:11 +0000 (13:57 -0500)]
Remove bt_/BT_ prefixes throughout
Since this is not longer part of Babeltrace, remove the bt_/BT_
prefixes. This was done mechanically using:
sed -i -e 's/BT_ARGPAR/ARGPAR/g' -e 's/bt_argpar/argpar/g'
Hopefully there isn't too much collateral damage.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Thu, 5 Dec 2019 18:27:09 +0000 (13:27 -0500)]
Fix comments in bt_argpar_item_array, data -> items
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 4 Dec 2019 22:58:36 +0000 (17:58 -0500)]
Strip trailing spaces
Simon Marchi [Wed, 4 Dec 2019 22:33:56 +0000 (17:33 -0500)]
Add bootstrap script
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 4 Dec 2019 21:12:56 +0000 (16:12 -0500)]
Add .gitignore
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 4 Dec 2019 22:33:56 +0000 (17:33 -0500)]
Add build system, remove dependency on glib, add TAP library
This commit...
* adds an automake-based system.
* removes glib dependencies from the library code (i.e. not from the tests),
replacing them with home-grown code.
* sets up the tests to run using the TAP library [1].
[1] https://github.com/shlomif/libtap-prev
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 4 Dec 2019 16:51:08 +0000 (11:51 -0500)]
Initial commit
Copy source and tests from the babeltrace repository, commit:
23256fd15c8ac7d1faaa3e37d0df2e225e90a6c6
bt2: reverse order of printed causes in _Error.__str__
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
This page took 0.025486 seconds and 4 git commands to generate.