diff options
author | Justus Winter <[email protected]> | 2017-06-19 14:29:08 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2017-06-19 14:51:31 +0000 |
commit | b4628b4a23d7e8b55ef3f17d79ca86ae77cbc685 (patch) | |
tree | 922c349e33fc1d56e51bfa043fa5a98b192035fb | |
parent | gpgscm: Improve error handling of foreign functions. (diff) | |
download | libgpg-error-b4628b4a23d7e8b55ef3f17d79ca86ae77cbc685.tar.gz libgpg-error-b4628b4a23d7e8b55ef3f17d79ca86ae77cbc685.zip |
gpgscm: Improve option parsing.
* tests/gpgscm/tests.scm (flag): Accept arguments of the form
'--foo=bar'.
Signed-off-by: Justus Winter <[email protected]>
-rw-r--r-- | tests.scm | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -766,7 +766,8 @@ ;; Command line flag handling. Returns the elements following KEY in ;; ARGUMENTS up to the next argument, or #f if KEY is not in -;; ARGUMENTS. +;; ARGUMENTS. If 'KEY=XYZ' is encountered, then the singleton list +;; containing 'XYZ' is returned. (define (flag key arguments) (cond ((null? arguments) @@ -777,6 +778,10 @@ (if (or (null? args) (string-prefix? (car args) "--")) (reverse acc) (loop (cons (car args) acc) (cdr args))))) + ((string-prefix? (car arguments) (string-append key "=")) + (list (substring (car arguments) + (+ (string-length key) 1) + (string-length (car arguments))))) ((string=? "--" (car arguments)) #f) (else @@ -784,6 +789,7 @@ (assert (equal? (flag "--xxx" '("--yyy")) #f)) (assert (equal? (flag "--xxx" '("--xxx")) '())) (assert (equal? (flag "--xxx" '("--xxx" "yyy")) '("yyy"))) +(assert (equal? (flag "--xxx" '("--xxx=foo" "yyy")) '("foo"))) (assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz")) '("yyy" "zzz"))) (assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz" "--")) '("yyy" "zzz"))) (assert (equal? (flag "--xxx" '("--xxx" "yyy" "--" "zzz")) '("yyy"))) |