diff options
author | Arun Isaac | 2021-10-12 16:21:57 +0530 |
---|---|---|
committer | Arun Isaac | 2021-10-12 16:30:39 +0530 |
commit | b47e6fdbe7e8550dd10eee077278d0007137f37f (patch) | |
tree | 3f79821a56b98b1f2f2cb6da249dccdc4cab2bc6 | |
parent | e553d183d0468cb67c0aa850538b886ed557635d (diff) | |
download | ccwl-b47e6fdbe7e8550dd10eee077278d0007137f37f.tar.gz ccwl-b47e6fdbe7e8550dd10eee077278d0007137f37f.tar.lz ccwl-b47e6fdbe7e8550dd10eee077278d0007137f37f.zip |
scripts: Allow compiling to graphviz.
* scripts/ccwl.in: Import (ccwl graphviz).
(main): Implement the --to option.
-rwxr-xr-x | scripts/ccwl.in | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/scripts/ccwl.in b/scripts/ccwl.in index d47b64b..300bc34 100755 --- a/scripts/ccwl.in +++ b/scripts/ccwl.in @@ -21,7 +21,7 @@ ;;; Commentary: -;; This script compiles a CCWL workflow to CWL. +;; This script is the command-line interface to ccwl. ;;; Code: @@ -29,7 +29,8 @@ (srfi srfi-37) (ice-9 match) (ccwl ccwl) - (ccwl cwl)) + (ccwl cwl) + (ccwl graphviz)) (define (invalid-option opt name arg result) (error "Invalid option" name)) @@ -46,16 +47,33 @@ (match-lambda* ((program "compile" args ...) (let* ((args (args-fold args - (list %help-option) + (list (option (list #\t "to") #t #f + (lambda (opt name arg result) + (let ((supported (list "cwl" "graphviz"))) + (unless (member arg supported) + (scm-error 'misc-error + #f + "Invalid target ~A argument ~S. Supported targets are ~A." + (list (if (char? name) + (string #\- name) + (string-append "--" name)) + arg + (string-join supported ", ")) + #f))) + (acons 'to arg result))) + %help-option) invalid-option (lambda (arg result) (acons 'source-file arg result)) - '()))) + '((to . "cwl"))))) (when (or (assq 'help args) (not (assq-ref args 'source-file))) (display (format "Usage: ~a compile [OPTIONS] SOURCE-FILE Compile SOURCE-FILE. + -t, --to=TARGET compile SOURCE-FILE to TARGET language; + Supported targets are cwl (default) and graphviz. + " program) (current-error-port)) @@ -63,8 +81,12 @@ Compile SOURCE-FILE. ;; FIXME: Compiling ccwl files fails since the workflow macro is ;; unable to access command definitions. (set! %load-should-auto-compile #f) - (workflow->cwl (load (canonicalize-path (assq-ref args 'source-file))) - (current-output-port)))) + (let ((to (assq-ref args 'to))) + ((cond + ((string=? to "cwl") workflow->cwl) + ((string=? to "graphviz") workflow->graphviz)) + (load (canonicalize-path (assq-ref args 'source-file))) + (current-output-port))))) ((program args ...) (let ((args (args-fold args (list %help-option) |