| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse_internal_s): Add fields no_registry
and registry.
(initialize): Init them.
(emulated_registry_lookup): New.
(handle_meta_getenv): Use it.
* tests/etc/t-argparse.conf: Add a getreg meta command.
* tests/t-argparse.c (opt): Add a disable-akr command.
* tests/etc/Registry: New.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
--
GnuPG-bug-id: 6978
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (struct variable_s): New.
(struct _gpgrt_argparse_internal_s): New fields expand, if_cond,
if_active and vartbl.
(deinitialize): Free vartbl.
(initialize): Clear new vars.
(get_var): New.
(substitute_vars): New.
(set_variable): New.
(handle_meta_if): New.
(handle_meta_let): New.
(handle_meta_getenv): New.
(handle_meta_echo): Re-implement in terms of variabale substitution.
(handle_meta_expand): New.
(handle_metacmd): Add new meta commands.
(_gpgrt_argparse): Expand values if enabled.
(_gpgrt_argparse): Take care of conditions.
(_gpgrt_argparser): Reset some state at the end of a file.
* tests/etc/t-argparse.conf: Adjust for changed system variables.
* tests/t-argparse.c (my_strusage): Add a value for a version test.
(main): Add new option "street".
* tests/t-argparse.conf: A couple if additions for the new conditions.
--
The whole thing is actually only for here for doing this
[let tkey HKLM\Foo\Bar\GnuPG:trusted-key-1]
[if $tkey]
trusted-key $tkey
[fi]
But we are hackers and tend to make things more complicated^Wflexible.
Documentation will be done eventually.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_OPT_HEADER): New.
(ARGPARSE_OPT_VERBATIM): New.
(ARGPARSE_verbatim): New.
(ARGPARSE_header): New.
* src/argparse.c (show_help): Implement them.
--
These two macros are useful for custom help screens. In contrast to
the ARGPARSE_group hack they do not need a short option number (we use
1 here as a surrogate) and not the "@" hack. Thus already translated
strings can be used. ARGPARSE_header further allows to specify a
symbolic name for the group and does some minor formatting. If such a
symbolic name is given --dump-option-table also emits this as a pseudo
option for consumption by GUIs which for example use tabs to group
options.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_FLAG_WITHATTR): New.
(ARGPARSE_ATTR_FORCE): New.
(ARGPARSE_ATTR_IGNORE): New.
(ARGPARSE_TYPE_MASK): Moved from argparse.c to here.
* src/argparse.c: Always use macros for constants.
(_gpgrt_argparse): Handle ARGPARSE_FLAG_WITHATTR.
(arg_parse): Ditto.
* tests/t-argparse.c (main): Add commented test case.
--
This is a ABI compatible hack to allow the ignore and force attributes
as well as to return which option has been ignored in a user file or
on the command line.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (opttable_t): Add new flags forced, ignore, and
explicit_ignore.
(struct _gpgrt_argparse_internal_s): Change flags to bitflags. Add
several flags to support meta commands.
(initialize): Clear them.
(handle_meta_user): Use the new verbose flag.
(handle_meta_force): Implement.
(handle_meta_ignore): Implement.
(handle_meta_echo): Support "-echo".
(handle_meta_verbose): New.
(handle_metacmd): New meta command verbose. Add always flag and move
the detection of unexpected meta commands to here.
(_gpgrt_argparse): Make use of the ignore and forced meta commands.
(finish_read_sys): New.
(_gpgrt_argparser): Support the verbose flag. Call finish_read_sys.
(arg_parse): Ignore non-explicit ignored and all forced options.
* tests/t-argparse.c (main): Fix printing of the ARGPARSE_CONFFILE
case. New option 'M'.
* tests/t-argparse.conf, tests/etc/t-argparse.conf: Various changes to
test the new meta commands.
--
For the command line we print a diagnostic if an ignored or forced
options is used. However, we do not ignore options which are only set
via [ignore-all]. The rationale for the latter is that an
administrator can't be be required to unignore all options used by all
modes, of say gpgme.
Documentation of the meta commands will for now be added to GnuPG.
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_INVALID_META): New
(ARGPARSE_UNKNOWN_META, ARGPARSE_UNEXPECTED_META): New.
* src/argparse.c (struct _gpgrt_argparse_internal_s): Add flag
insysconfig.
(initialize): Init flag. Add error strings.
(_gpgrt_argparser): Set that flag.
(_gpgrt_argparse): Add parsing of meta commands.
* tests/etc/t-argparse.conf: Add some test cases.
* tests/t-argparse.conf: Ditto.
* tests/t-argparse.c (main): Die only after printing all warnings.
--
Noe that this is just the framework to add meta commands to the global
config file. We also need to get away from fixes test config files
and create them on the fly to that we are able to test also errors.
GnuPG-bug-id: 4788
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gpg-error.h.in (GPGRT_CONFDIR_USER, GPGRT_CONFDIR_SYS): New consts.
(ARGPARSE_FLAG_SYS, ARGPARSE_FLAG_USER, ARGPARSE_FLAG_VERBOSE)
(ARGPARSE_NO_CONFFILE, ARGPARSE_CONFFILE, ARGPARSE_OPT_CONFFILE): New
consts.
(ARGPARSE_conffile, ARGPARSE_noconffile): New macros.
(gpgrt_set_confdir): New func.
(gpgrt_argparser): New func.
* src/argparse.c (confdir): New var.
(enum argparser_states): New.
(struct _gpgrt_argparse_internal_s): Add a couple of new fields.
(initialize): Init them.
(any_opt_conffile): New.
(_gpgrt_argparser): New.
(_gpgrt_set_confdir): New.
* src/visibility.c (gpgrt_argparser): New.
(gpgrt_set_confdir): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add those functions.
* tests/t-argparse.c (main): Reworked.
* tests/etc/t-argparse.conf: New file.
* tests/t-argparse.conf: New file.
--
gpgrt_argparser is a high level version of gpgrt_argparse. It handles
reading of configuration files internally and allows allows for a
global configuration file. The design is so that it minimizes the
work to replace the existing option parsing in gpg and friends by this
one and to allow global configuration files for them.
This is the just the basic code which should allow replacement of the
parsers. A forthcoming patch will implement flags for options given
in the global config file.
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
| |
--
|
|
* src/visibility.c (gpgrt_argparse): New.
(gpgrt_strusage): New.
(gpgrt_set_strusage): New.
(gpgrt_set_usage_outfnc): New.
(gpgrt_set_fixed_string_mapper): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add new functions.
* src/gpg-error.h.in: Add ARGPARSE macros from the former argparse.h.
(gpgrt_argparse_t): New.
(gpgrt_opt_t): New.
* configure.ac (AH_BOTTOM): Request argparse macros.
* src/Makefile.am (libgpg_error_la_SOURCES): Add argparse.c.
* src/argparse.h: Remove.
* src/argparse.c: Revamp to fit into libgpg-error.
(_gpgrt_argparse): New.
(_gpgrt_usage): Rename from usage.
(_gpgrt_strusage): Rename from strusage. Define two new levels and
templates for three common licenses.
(_gpgrt_set_strusage): Rename from set_strusage.
(_gpgrt_set_usage_outfnc): New.
(_gpgrt_set_fixed_string_mapper): New.
* tests/t-argparse.c: New.
--
These functions are in use by GnuPG and other software for 20 years
and it makes sense to have them always available instead of copying
and maintaing the source in several projects. Note that there are
minor changes in the API compared to GnuPG.
Signed-off-by: Werner Koch <[email protected]>
|