graph: Factorize 'lookup-backend'.
* guix/graph.scm (lookup-backend): New procedure. * guix/scripts/graph.scm (lookup-backend): Remove. * guix/scripts/system.scm (lookup-backend): Remove. * po/guix/POTFILES.in: Add 'guix/graph.scm'.master
parent
625fa3cfe8
commit
f5a94b3a9f
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015, 2016, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2015-2016, 2020-2022 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
|
@ -22,10 +22,13 @@
|
|||
#:use-module (guix monads)
|
||||
#:use-module (guix records)
|
||||
#:use-module (guix sets)
|
||||
#:autoload (guix diagnostics) (formatted-message)
|
||||
#:autoload (guix i18n) (G_)
|
||||
#:use-module (rnrs io ports)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:use-module (srfi srfi-26)
|
||||
#:use-module (srfi srfi-34)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 vlist)
|
||||
#:export (node-type
|
||||
|
@ -47,6 +50,8 @@
|
|||
%graph-backends
|
||||
%d3js-backend
|
||||
%graphviz-backend
|
||||
lookup-backend
|
||||
|
||||
graph-backend?
|
||||
graph-backend
|
||||
graph-backend-name
|
||||
|
@ -335,6 +340,13 @@ nodeArray.push(nodes[\"~a\"]);~%"
|
|||
%d3js-backend
|
||||
%cypher-backend))
|
||||
|
||||
(define (lookup-backend name)
|
||||
"Return the graph backend called NAME. Raise an error if it is not found."
|
||||
(or (find (lambda (backend)
|
||||
(string=? (graph-backend-name backend) name))
|
||||
%graph-backends)
|
||||
(raise (formatted-message (G_ "~a: unknown graph backend") name))))
|
||||
|
||||
(define* (export-graph sinks port
|
||||
#:key
|
||||
reverse-edges? node-type (max-depth +inf.0)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
|
@ -429,13 +429,6 @@ package modules, while attempting to retain user package modules."
|
|||
%node-types)
|
||||
(leave (G_ "~a: unknown node type~%") name)))
|
||||
|
||||
(define (lookup-backend name)
|
||||
"Return the graph backend called NAME. Raise an error if it is not found."
|
||||
(or (find (lambda (backend)
|
||||
(string=? (graph-backend-name backend) name))
|
||||
%graph-backends)
|
||||
(leave (G_ "~a: unknown backend~%") name)))
|
||||
|
||||
(define (list-node-types)
|
||||
"Print the available node types along with their synopsis."
|
||||
(display (G_ "The available node types are:\n"))
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
delete-matching-generations)
|
||||
#:autoload (guix scripts pull) (channel-commit-hyperlink)
|
||||
#:autoload (guix graph) (export-graph node-type
|
||||
graph-backend-name %graph-backends)
|
||||
graph-backend-name lookup-backend)
|
||||
#:use-module (guix scripts graph)
|
||||
#:use-module (guix scripts system reconfigure)
|
||||
#:use-module (guix build utils)
|
||||
|
@ -887,13 +887,6 @@ Run 'herd status' to view the list of services on your system.\n"))))))
|
|||
(register-root* (list output) gc-root))
|
||||
(return output)))))))))
|
||||
|
||||
(define (lookup-backend name) ;TODO: factorize
|
||||
"Return the graph backend called NAME. Raise an error if it is not found."
|
||||
(or (find (lambda (backend)
|
||||
(string=? (graph-backend-name backend) name))
|
||||
%graph-backends)
|
||||
(leave (G_ "~a: unknown backend~%") name)))
|
||||
|
||||
(define* (export-extension-graph os port
|
||||
#:key (backend (lookup-backend "graphviz")))
|
||||
"Export the service extension graph of OS to PORT using BACKEND."
|
||||
|
|
|
@ -66,6 +66,7 @@ guix/ci.scm
|
|||
guix/cve.scm
|
||||
guix/git-authenticate.scm
|
||||
guix/gnupg.scm
|
||||
guix/graph.scm
|
||||
guix/lint.scm
|
||||
guix/scripts/download.scm
|
||||
guix/scripts/package.scm
|
||||
|
|
Reference in New Issue