about summary refs log tree commit diff
path: root/ccwl/ccwl.scm
diff options
context:
space:
mode:
authorArun Isaac2023-10-15 12:13:58 +0100
committerArun Isaac2023-10-15 12:41:39 +0100
commitcb66af826596b7bfba0fa45f8eb25fcf1613bc13 (patch)
tree15631d090f37869319f3f30bd875a3af6f1a7237 /ccwl/ccwl.scm
parent3063c33634d4a25ba99a2c884dd8bf04e519f914 (diff)
downloadccwl-cb66af826596b7bfba0fa45f8eb25fcf1613bc13.tar.gz
ccwl-cb66af826596b7bfba0fa45f8eb25fcf1613bc13.tar.lz
ccwl-cb66af826596b7bfba0fa45f8eb25fcf1613bc13.zip
ccwl: Make #:stderr and #:stdout first class parameters.
#:stderr and #:stdout, especially #:stdout, are commonly
required. They ought to be first class parameters and not tucked away
into #:other.

* ccwl/ccwl.scm (<command>)[stderr, stdout]: New fields.
* ccwl/ccwl.scm (command): Accept #:stderr and #:stdout as first class
parameters.
* ccwl/cwl.scm (command->cwl-scm): Serialize stderr and stdout fields.
* doc/capture-stdout.scm (print),
doc/decompress-compile-run.scm (run), doc/checksum.scm (md5sum,
sha1sum, sha256sum), doc/spell-check.scm (find-misspellings): Capture
stdout in file.
* doc/checksum.scm, doc/decompress-compile-run.scm:
* doc/ccwl.skb (Tutorial)[Capturing the standard output stream of a
command]: Document #:stdout first class parameter.
* doc/ccwl.skb (Tutorial)[Workflow with multiple steps]: Capture
stdout in explicitly named files.
* tests/ccwl.scm ("commands with non-string #:stderr parameters must
raise a &ccwl-violation condition", "commands with non-string #:stdout
parameters must raise a &ccwl-violation condition"): New tests.
Diffstat (limited to 'ccwl/ccwl.scm')
-rw-r--r--ccwl/ccwl.scm20
1 files changed, 18 insertions, 2 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index f64830c..05cb6e6 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -42,6 +42,8 @@
             command-outputs
             command-args
             command-stdin
+            command-stderr
+            command-stdout
             command-other
             cwl-workflow?
             cwl-workflow
@@ -186,12 +188,14 @@
     (_ (error "Invalid output:" (syntax->datum output-spec)))))
 
 (define-immutable-record-type <command>
-  (make-command inputs outputs args stdin other)
+  (make-command inputs outputs args stdin stderr stdout other)
   command?
   (inputs command-inputs set-command-inputs)
   (outputs command-outputs)
   (args command-args)
   (stdin command-stdin)
+  (stderr command-stderr)
+  (stdout command-stdout)
   (other command-other))
 
 (define-immutable-record-type <cwl-workflow>
@@ -300,7 +304,7 @@ RUN-ARGS. If such an input is not present in RUN-ARGS, return #f."
                     (condition (ccwl-violation extra)
                                (formatted-message "Unexpected extra positional argument ~a in command definition"
                                                   (syntax->datum extra))))))))
-         (apply (syntax-lambda** (#:key stdin #:key* inputs outputs run other)
+         (apply (syntax-lambda** (#:key stdin stderr stdout #:key* inputs outputs run other)
                   (when (null? run)
                     (raise-exception
                      (condition (ccwl-violation x)
@@ -332,6 +336,18 @@ RUN-ARGS. If such an input is not present in RUN-ARGS, return #f."
                                                  (syntax->datum x)))))
                                    run))
                      #,(and stdin #`'#,stdin)
+                     #,(if (and stderr
+                                (not (string? (syntax->datum stderr))))
+                           (raise-exception
+                            (condition (ccwl-violation stderr)
+                                       (formatted-message "#:stderr parameter must be a string")))
+                           stderr)
+                     #,(if (and stdout
+                                (not (string? (syntax->datum stdout))))
+                           (raise-exception
+                            (condition (ccwl-violation stdout)
+                                       (formatted-message "#:stdout parameter must be a string")))
+                           stdout)
                      (list #,@other)))
                 #'(args ...)))))))