gwl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/3] graph: Add output switch


From: Ricardo Wurmus
Subject: Re: [PATCH 3/3] graph: Add output switch
Date: Sun, 12 Jun 2022 11:05:14 +0200
User-agent: mu4e 1.6.10; emacs 28.1

Hi Olivier,

> diff --git a/gwl/main.scm b/gwl/main.scm
> index 78494fd..7f0fd14 100644
> --- a/gwl/main.scm
> +++ b/gwl/main.scm
> @@ -17,6 +17,7 @@
>  (define-module (gwl main)
>    #:use-module (config)
>    #:use-module (config api)
> +  #:use-module ((guix build utils) #:select (mkdir-p))
>    #:use-module (gwl errors)
>    #:use-module (gwl process-engines)
>    #:use-module (gwl web-interface)
> @@ -95,5 +96,15 @@
>             (parameterize ((*current-filename* file-name))
>               (match (load-workflow file-name)
>                 ((? workflow? wf)
> -                (format #t "~a\n" (workflow->dot wf)))
> +
> +                (define (flush)
> +                  (format #t "~a\n" (workflow->dot wf)))
> +
> +                (define output (%config 'output))
> +
> +                (if output
> +                    (begin
> +                      (mkdir-p (dirname output))
> +                      (with-output-to-file output flush))
> +                    (flush)))
>                 (_ (leave (G_ "Failed to process the workflow.~%")))))))))))

The name “flush” really confused me, because it already has a meaning
with regard to buffering.

I’d prefer to rewrite this

   (format #t "~a\n" (workflow->dot wf))

to

   (format port "~a\n" (workflow->dot wf))

and then arrange for port to either be (current-output-port) or some
file port.

-- 
Ricardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]