about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--e2e-tests/jobs/unseparated-prefix-arguments.yaml1
-rw-r--r--e2e-tests/tests.yaml9
-rw-r--r--e2e-tests/tools/unseparated-prefix-arguments.scm3
-rw-r--r--ravanan/reader.scm18
-rw-r--r--ravanan/work/command-line-tool.scm44
5 files changed, 56 insertions, 19 deletions
diff --git a/e2e-tests/jobs/unseparated-prefix-arguments.yaml b/e2e-tests/jobs/unseparated-prefix-arguments.yaml
new file mode 100644
index 0000000..e179c1b
--- /dev/null
+++ b/e2e-tests/jobs/unseparated-prefix-arguments.yaml
@@ -0,0 +1 @@
+message: foo
diff --git a/e2e-tests/tests.yaml b/e2e-tests/tests.yaml
index 6604e39..70f90f1 100644
--- a/e2e-tests/tests.yaml
+++ b/e2e-tests/tests.yaml
@@ -250,3 +250,12 @@
       class: File
       size: 8
       checksum: sha1$d53a205a336e07cf9eac45471b3870f9489288ec
+- id: unseparated-prefix-arguments
+  doc: Prefix arguments with separate as false
+  tool: tools/unseparated-prefix-arguments.cwl
+  job: jobs/unseparated-prefix-arguments.yaml
+  output:
+    output_message:
+      class: File
+      size: 12
+      checksum: sha1$598114d347c67f3f6142f60a4b5afcb3482f27a8
diff --git a/e2e-tests/tools/unseparated-prefix-arguments.scm b/e2e-tests/tools/unseparated-prefix-arguments.scm
new file mode 100644
index 0000000..03f68e2
--- /dev/null
+++ b/e2e-tests/tools/unseparated-prefix-arguments.scm
@@ -0,0 +1,3 @@
+(command #:inputs (message #:type string)
+         #:run "echo" ("-a" message #:separate? #f) ("-b" "bar" #:separate? #f)
+         #:outputs (output_message #:type stdout))
diff --git a/ravanan/reader.scm b/ravanan/reader.scm
index bb825ed..35545dd 100644
--- a/ravanan/reader.scm
+++ b/ravanan/reader.scm
@@ -156,6 +156,17 @@ the @code{required} field when it is not specified."
     (vector `(("pattern" . ,secondary-files)
               ("required" . ,default-required))))))
 
+(define (normalize-command-line-binding binding)
+  "Normalize @code{CommandLineBinding} @var{binding}."
+  (assoc-set binding
+    (cons "separate"
+          (cond
+           ((assoc "separate" binding)
+            => (match-lambda
+                 ((_ . separate)
+                  (coerce-type separate 'boolean))))
+           (else #t)))))
+
 (define (normalize-formal-input input)
   "Normalize formal @var{input}."
   (maybe-assoc-set input
@@ -167,7 +178,10 @@ the @code{required} field when it is not specified."
     (cons "secondaryFiles"
           (maybe-bind (maybe-assoc-ref (just input) "secondaryFiles")
                       (compose just
-                               (cut normalize-secondary-files <> #t))))))
+                               (cut normalize-secondary-files <> #t))))
+    (cons "inputBinding"
+          (maybe-bind (maybe-assoc-ref (just input) "inputBinding")
+                      (compose just normalize-command-line-binding)))))
 
 (define (normalize-formal-output output)
   "Normalize formal @var{output}."
@@ -192,7 +206,7 @@ the @code{required} field when it is not specified."
                          ((string? argument)
                           `(("valueFrom" . ,argument)))
                          ((list? argument)
-                          argument)
+                          (normalize-command-line-binding argument))
                          (else
                           (error "Invalid argument" argument))))
                       arguments))))
diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm
index 95d69f5..cb945f9 100644
--- a/ravanan/work/command-line-tool.scm
+++ b/ravanan/work/command-line-tool.scm
@@ -296,12 +296,13 @@ condition on unsupported URI schemes."
       json->scm)))
 
 (define-immutable-record-type <command-line-binding>
-  (command-line-binding position prefix type value item-separator)
+  (command-line-binding position prefix type value separate? item-separator)
   command-line-binding?
   (position command-line-binding-position)
   (prefix command-line-binding-prefix)
   (type command-line-binding-type)
   (value command-line-binding-value)
+  (separate? command-line-binding-separate?)
   (item-separator command-line-binding-item-separator))
 
 (define (command-line-binding->args binding)
@@ -332,17 +333,20 @@ the G-expressions are inserted."
                       (just (list (string-join args item-separator))))
                     args))))))
      (else
-      (append (maybe->list prefix)
-              (list (case type
-                      ((string)
-                       value)
-                      ((int float)
-                       (number->string value))
-                      ((File)
-                       (assoc-ref* value "path"))
-                      (else
-                       (user-error "Invalid formal input type ~a"
-                                   type)))))))))
+      (let ((args (append (maybe->list prefix)
+                          (list (case type
+                                  ((string)
+                                   value)
+                                  ((int float)
+                                   (number->string value))
+                                  ((File)
+                                   (assoc-ref* value "path"))
+                                  (else
+                                   (user-error "Invalid formal input type ~a"
+                                               type)))))))
+        (if (command-line-binding-separate? binding)
+            args
+            (list (string-join args ""))))))))
 
 (define (build-command base-command arguments formal-inputs inputs)
   "Return a list of @code{<command-line-binding>} objects for a
@@ -351,7 +355,7 @@ the G-expressions are inserted."
 @code{<command-line-binding>} objects may be strings or G-expressions. The
 G-expressions may reference @var{inputs} and @var{runtime} variables that must
 be defined in the context in which the G-expressions are inserted."
-  (define (value->command-line-binding position prefix value)
+  (define (value->command-line-binding position prefix value separate?)
     (let ((type (object-type value)))
       (cond
        ((cwl-array-type? type)
@@ -361,11 +365,13 @@ be defined in the context in which the G-expressions are inserted."
                               (vector-map (cut value->command-line-binding
                                                %nothing
                                                %nothing
-                                               <>)
+                                               <>
+                                               #f)
                                           value)
+                              separate?
                               %nothing))
        (else
-        (command-line-binding position prefix type value %nothing)))))
+        (command-line-binding position prefix type value separate? %nothing)))))
 
   (define (argument->command-line-binding i argument)
     (value->command-line-binding (cond
@@ -373,7 +379,8 @@ be defined in the context in which the G-expressions are inserted."
                                    => string->number)
                                   (else i))
                                  (maybe-assoc-ref (just argument) "prefix")
-                                 (assoc-ref* argument "valueFrom")))
+                                 (assoc-ref* argument "valueFrom")
+                                 (assoc-ref* argument "separate")))
 
   (define (collect-bindings ids+inputs+types+bindings)
     (map id+input+type-tree+binding->command-line-binding
@@ -399,7 +406,8 @@ be defined in the context in which the G-expressions are inserted."
                    (just (string->number position)))
                  ;; FIXME: Why a default value of 0?
                  0))
-               (prefix (maybe-assoc-ref binding "prefix")))
+               (prefix (maybe-assoc-ref binding "prefix"))
+               (separate? (maybe-bind binding (cut assoc-ref* <> "separate"))))
            (cond
             ;; Recurse over array types.
             ;; TODO: Implement record and enum types.
@@ -416,12 +424,14 @@ be defined in the context in which the G-expressions are inserted."
                                            (maybe-assoc-ref (just type-tree)
                                                             "inputBinding"))))
                                   input)
+              separate?
               (maybe-assoc-ref binding "itemSeparator")))
             (else
              (command-line-binding position
                                    prefix
                                    matched-type
                                    (apply json-ref inputs id)
+                                   separate?
                                    %nothing))))))))
 
   ;; For details of this algorithm, see ยง4.1 Input binding of the CWL