unofficial mirror of gwl-devel@gnu.org
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Olivier Dion <olivier.dion@polymtl.ca>
Cc: gwl-devel@gnu.org
Subject: Re: [PATCH 3/3] graph: Add output switch
Date: Sun, 12 Jun 2022 11:05:14 +0200	[thread overview]
Message-ID: <87r13u1c88.fsf@elephly.net> (raw)
In-Reply-To: <20220606194900.27725-3-olivier.dion@polymtl.ca>


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	other threads:[~2022-06-12  9:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 18:32 [PATCH] gwl/ui: Check for log-events configuration Olivier Dion
2022-06-04 15:00 ` Ricardo Wurmus
2022-06-04 15:10   ` Olivier Dion via
2022-06-06 10:32     ` Ricardo Wurmus
2022-06-06 13:25       ` Olivier Dion via
2022-06-06 18:51         ` Olivier Dion via
2022-06-06 19:48 ` [PATCH 1/3] " Olivier Dion
2022-06-06 19:48   ` [PATCH 2/3] gwl/config: Share log-event switch with subcommands Olivier Dion
2022-06-12  9:03     ` Ricardo Wurmus
2022-06-06 19:49   ` [PATCH 3/3] graph: Add output switch Olivier Dion
2022-06-12  9:05     ` Ricardo Wurmus [this message]
2022-06-12  9:08   ` [PATCH 1/3] gwl/ui: Check for log-events configuration Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.guixwl.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r13u1c88.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=gwl-devel@gnu.org \
    --cc=olivier.dion@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).