unofficial mirror of gwl-devel@gnu.org
 help / color / mirror / Atom feed
From: Olivier Dion <olivier.dion@polymtl.ca>
To: Olivier Dion <olivier.dion@polymtl.ca>, gwl-devel@gnu.org
Subject: [PATCH 3/3] graph: Add output switch
Date: Mon,  6 Jun 2022 15:49:00 -0400	[thread overview]
Message-ID: <20220606194900.27725-3-olivier.dion@polymtl.ca> (raw)
In-Reply-To: <20220606194900.27725-1-olivier.dion@polymtl.ca>

---
 gwl/config.scm.in |  9 ++++++++-
 gwl/main.scm      | 13 ++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/gwl/config.scm.in b/gwl/config.scm.in
index 728eec5..1e0b4d0 100644
--- a/gwl/config.scm.in
+++ b/gwl/config.scm.in
@@ -148,7 +148,14 @@ workflow.")
 format) of the specified workflow.")
       (keywords
        (list
-        log-event-switch))
+        log-event-switch
+        (switch
+         (name 'output)
+         (character #\o)
+         (default #false)
+         (test string?)
+         (synopsis "Write dot graph to <file>.")
+         (example "<file>"))))
       (arguments
        (list
         (argument
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.~%")))))))))))
-- 
2.36.1



  parent reply	other threads:[~2022-06-06 19:49 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   ` Olivier Dion [this message]
2022-06-12  9:05     ` [PATCH 3/3] graph: Add output switch Ricardo Wurmus
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=20220606194900.27725-3-olivier.dion@polymtl.ca \
    --to=olivier.dion@polymtl.ca \
    --cc=gwl-devel@gnu.org \
    /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).