summaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2021-05-17 02:17:24 +0530
committerArun Isaac2021-05-17 02:19:20 +0530
commit495bdf7812f4f793eb1fad03d75d40e97d1aa745 (patch)
tree876c1ac7295a0e6f0844159b3c37d26bf5d4b5e9 /ccwl
parent32f4fe055882e7d9bc45d9acb85b72a4743f7b18 (diff)
downloadccwl-495bdf7812f4f793eb1fad03d75d40e97d1aa745.tar.gz
ccwl-495bdf7812f4f793eb1fad03d75d40e97d1aa745.tar.lz
ccwl-495bdf7812f4f793eb1fad03d75d40e97d1aa745.zip
Abstract out command variable reflection.
* ccwl/ccwl.scm (command-variable, command-syntax->object): New functions. (workflow-steps): Use command-variable and command-syntax->object.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ccwl.scm15
1 files changed, 11 insertions, 4 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index 1d370fa..1469471 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -294,6 +294,15 @@
;; Global input/output
(symbol->string (key-name key))))
+(define (command-variable command-syntax)
+ "Return the corresponding module variable if command described by
+COMMAND-SYNTAX is a valid defined ccwl command. Else, return #f."
+ (module-variable (current-module)
+ (syntax->datum command-syntax)))
+
+(define (command-syntax->object command-syntax)
+ (variable-ref (command-variable command-syntax)))
+
(define (workflow-steps x input-keys)
"Traverse ccwl source X and return list of steps. INPUT-KEYS is a
list of supplied input <key> objects."
@@ -315,12 +324,10 @@ list of supplied input <key> objects."
;; messages.
(begin
;; Test for undefined command.
- (unless (module-variable (current-module)
- (syntax->datum #'command))
+ (unless (command-variable #'command)
(error "Undefined ccwl command:" (syntax->datum #'command)))
(let ((input-key-symbols (map key-name input-keys))
- (command-object (module-ref (current-module)
- (syntax->datum #'command)))
+ (command-object (command-syntax->object #'command))
(step-id (syntax->datum #'step-id)))
;; Test for missing required parameters.
;; TODO: Filter out optional parameters.