Introduce argparse library (which was inspired by the thread [1]), compared with getopt, it makes it easy to write user-friendly command-like program.
Note: the 2nd commit contains usage examples. [1] https://patchwork.dpdk.org/project/dpdk/patch/20231105054539.22303-2-fengcheng...@huawei.com/ Chengwen Feng (8): eal: introduce more macro for bit definition argparse: add argparse library argparse: support verify argument config argparse: support parse parameters argparse: provide parsing known type API argparse: support parse unsigned base type argparse: pretty help info examples/dma: replace getopt with argparse --- v3: - Fix argparse_autotest asan fail due to don't free memory. - When a parsing error occurs, display exact parameter name (long_name or short_name). v2: - Refine argparse_lib.rst which address Stephen's comments. - Fix following which address Thomas's comments: 1. Redefine new introduce macros. 2. Squashed the test commit to feature commit. 3. Drop the arguments' defines and direct place in obj. - Use RTE_LOG_LINE marco to impl log. - Update MAINTAINERS file. MAINTAINERS | 5 + app/test/meson.build | 1 + app/test/test_argparse.c | 857 +++++++++++++++++++++++++ doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/argparse_lib.rst | 185 ++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/rel_notes/release_24_03.rst | 5 + examples/dma/dmafwd.c | 269 ++++---- examples/dma/meson.build | 2 +- lib/argparse/meson.build | 7 + lib/argparse/rte_argparse.c | 788 +++++++++++++++++++++++ lib/argparse/rte_argparse.h | 217 +++++++ lib/argparse/version.map | 8 + lib/eal/include/rte_bitops.h | 64 ++ lib/meson.build | 1 + 16 files changed, 2258 insertions(+), 154 deletions(-) create mode 100644 app/test/test_argparse.c create mode 100644 doc/guides/prog_guide/argparse_lib.rst create mode 100644 lib/argparse/meson.build create mode 100644 lib/argparse/rte_argparse.c create mode 100644 lib/argparse/rte_argparse.h create mode 100644 lib/argparse/version.map -- 2.17.1