summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-04-03 21:27:05 +0200
committerWerner Koch <wk@gnupg.org>2020-04-03 21:27:05 +0200
commitd843d260f5502ba90a2a35dfe202439f32b0e9aa (patch)
treeb5d04f75886c8c883aaef63746e03bbbed69ced0 /tests
parent85b5006d01fc64763a6e1f0d6cbda91c5cb709c1 (diff)
downloadlibgpg-error-d843d260f5502ba90a2a35dfe202439f32b0e9aa.tar.gz
core: Implement meta command [user] for the arg parser.
* src/sysutils.c (_gpgrt_getusername): New. * src/argparse.c (struct _gpgrt_argparse_internal_s): New flags user_* and store the current user. (initialize): Free new malloced field. Clear new flags. (handle_meta_user): Implement. (handle_metacmd): Implement user sections. Remove "group" meta command. (_gpgrt_argparse): Implement user sections. (finish_read_sys): Reset new vars. -- Implementing group would be somewhat complicated and it is doubtful whether this really makes sense and is manageable for the admin. Note that we have not yet implemented this for Windows. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/etc/t-argparse.conf30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/etc/t-argparse.conf b/tests/etc/t-argparse.conf
index 90b9935..4562c7c 100644
--- a/tests/etc/t-argparse.conf
+++ b/tests/etc/t-argparse.conf
@@ -3,11 +3,21 @@
# Options applied to all user's config files
#verbose
+# The meta comman decho simply prints the argument. With a hash
+# prefix it does not prepend the file name and line number. For
+# future compatibility do not use doallar signs.
[-echo Begin global config]
[verbose]
-[group :staff]
-# These option are applied to all users of the group staff up until
-# the next [group] or [user] statement.
+
+[user joy]
+# All the following options are applied only if the current user's
+# account name is "joy" (case-insensitive). This ends with the next
+# user statement. This does not affect "echo" and "verbose".
+
+# info is an alias for echo but only executed if a user secion is active.
+# For future compatibility do not use percent or dollar signs.
+[-info In user Joy]
+
[-verbose]
[+force]
# All following option are forced and thus ignored when set in user
@@ -37,8 +47,9 @@ not-my-option
#no-verbose
-[user john ]
-# Options for user john
+# Options applied only for user joy end here.
+[user wk ]
+[-info Options applied only for user wk follow]
# Change the immutable attribute back to mutable.
[-force]
@@ -47,13 +58,10 @@ not-my-option
# Default key for user john
my-option 42
-# Parsing stops for user WK here.
-
-[group * ]
-# Options for all group which have no specific group sections above
-
+# Options applied only for user joy end here.
[user *]
-# Options for all users which have no specific user sections above
+[-info All the following options are applied only if the]
+[-info current user has no specific section above.]
# The default algorithm for new keys is set to this.
a-long-option