From c3077419d1a6dc2a735fb3408aaf4842a46ea833 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 12 Oct 2021 14:56:59 +0530 Subject: scripts: Use args-fold. * scripts/ccwl.in: Import (srfi srfi-37). (invalid-option): New function. (main): Use args-fold to extract source filename. --- scripts/ccwl.in | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/ccwl.in b/scripts/ccwl.in index 8093fa9..ec5aa32 100755 --- a/scripts/ccwl.in +++ b/scripts/ccwl.in @@ -25,18 +25,28 @@ ;;; Code: -(use-modules (ice-9 match) +(use-modules (srfi srfi-37) + (ice-9 match) (ccwl ccwl) (ccwl cwl)) +(define (invalid-option opt name arg result) + (error "Invalid option" name)) + (define main (match-lambda* - ((_ "compile" input-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 input-file)) - (current-output-port))) + ((_ "compile" args ...) + (let* ((args (args-fold args + '() + invalid-option + (lambda (arg result) + (acons 'source-file arg result)) + '()))) + ;; 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)))) ((program _ ...) (format (current-error-port) "Usage: ~a compile input-file~%" -- cgit v1.2.3