diff options
-rw-r--r-- | ccwl/ccwl.scm | 49 | ||||
-rw-r--r-- | tests/ccwl.scm | 3 |
2 files changed, 30 insertions, 22 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 1b1d8fe..a476406 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -286,28 +286,33 @@ identifiers defined in the commands." (condition (ccwl-violation input) (formatted-message "Undefined input ~a" (syntax->datum input)))))))) - (map (lambda (x) - (syntax-case x () - ;; Replace input symbol with quoted symbol. - (input (identifier? #'input) - (begin - (ensure-input-is-defined #'input) - #''input)) - ;; Leave string as is. - (string-arg (string? (syntax->datum #'string-arg)) - #'string-arg) - ;; Replace prefixed input symbol with quoted symbol. - ((prefix input) (and (string? (syntax->datum #'prefix)) - (identifier? #'input)) - (begin - (ensure-input-is-defined #'input) - #''input)) - (_ - (raise-exception - (condition (ccwl-violation x) - (formatted-message "Invalid command element ~a. Command elements must either be input identifiers or literal strings." - (syntax->datum x))))))) - run))) + (append-map (lambda (x) + (syntax-case x () + ;; Replace input symbol with quoted symbol. + (input (identifier? #'input) + (begin + (ensure-input-is-defined #'input) + (list #''input))) + ;; Leave string as is. + (string-arg (string? (syntax->datum #'string-arg)) + (list #'string-arg)) + ;; Replace prefixed input symbol with quoted symbol. + ((prefix input) (and (string? (syntax->datum #'prefix)) + (identifier? #'input)) + (begin + (ensure-input-is-defined #'input) + (list #''input))) + ;; Flatten prefixed string arguments. They have no + ;; special meaning. + ((prefix string-arg) (and (string? (syntax->datum #'prefix)) + (string? (syntax->datum #'string-arg))) + (list #'prefix #'string-arg)) + (_ + (raise-exception + (condition (ccwl-violation x) + (formatted-message "Invalid command element ~a. Command elements must either be input identifiers or literal strings." + (syntax->datum x))))))) + run))) ;; TODO: Add fine-grained syntax checking. (define-syntax command diff --git a/tests/ccwl.scm b/tests/ccwl.scm index aef2a85..7cbb2c0 100644 --- a/tests/ccwl.scm +++ b/tests/ccwl.scm @@ -261,4 +261,7 @@ '(command #:run "echo" 42)) #f))) +(test-assert "tolerate prefixed string arguments in command definitions" + (command #:run "echo" ("-x" "foo"))) + (test-end "ccwl") |