From 83f4156efe0b01991bb09570b8bb90fccf8a9a51 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 18 Oct 2021 00:37:01 +0530 Subject: ccwl: Implement rename to rename keys between steps. * ccwl/ccwl.scm (collect-steps): Implement rename to rename keys between steps. --- ccwl/ccwl.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 27012ec..9b0c049 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -255,7 +255,7 @@ command is not defined, return #f." output keys and a list of steps. INPUT-KEYS is a list of supplied input keys. Keys are represented by objects, and steps are represented by objects." - (syntax-case x (pipe tee) + (syntax-case x (pipe tee rename) ;; pipe ((pipe expressions ...) (foldn (lambda (expression input-keys steps) @@ -268,6 +268,17 @@ represented by objects." ((tee expressions ...) (append-mapn (cut collect-steps <> input-keys) #'(expressions ...))) + ;; rename keys + ((rename mapping ...) + (values (map (lambda (key) + (or (any (match-lambda + ((new . old) + (and (eq? old (key-name key)) + (set-key-name key (keyword->symbol new))))) + (syntax->datum (pairify #'(mapping ...)))) + key)) + input-keys) + (list))) ;; commands with only a single input when only a single key is ;; available at this step and when no inputs are passed to it ((command (step-id)) -- cgit v1.2.3