Home GnuPG

argparser: Implement a command mode.

Description

argparser: Implement a command mode.

* src/gpg-error.h.in (ARGPARSE_FLAG_COMMAND): New.
* src/argparse.c (struct _gpgrt_argparse_internal_s): Add flags
explicit_cmd_mode, cmd_mode, and command_seen.
(initialize): Init them.  Mark default commands as commands.
(handle_meta_command): New.
(handle_metacmd): Add "command-mode" and "-command-mode".
(find_long_option): Add arg only_commands.
(arg_parse): Factor some code out to ...
(handle_special_commands): new.
(arg_parse): Implement the command-mode.
* tests/t-argparse.c (main): Add some testing code.

Details

Provenance
wernerAuthored on Feb 6 2024, 2:53 PM
Parents
rEae6fec7399d7: gpgrt-config: Avoid warning about literals for curly braces.
Branches
Unknown
Tags
Unknown
Tasks
T6978: Add a command mode to the option parser