import/json: Use json->code.
* guix/import/json.scm (json->code): Export procedure. * guix/scripts/import/json.scm (guix-import-json): Use json->code.
This commit is contained in:
parent
4f353c485d
commit
c893432320
@ -28,6 +28,7 @@
|
|||||||
#:use-module (srfi srfi-2)
|
#:use-module (srfi srfi-2)
|
||||||
#:use-module (srfi srfi-34)
|
#:use-module (srfi srfi-34)
|
||||||
#:export (json-fetch
|
#:export (json-fetch
|
||||||
|
json->code
|
||||||
json->scheme-file))
|
json->scheme-file))
|
||||||
|
|
||||||
(define* (json-fetch url
|
(define* (json-fetch url
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#:use-module (guix utils)
|
#:use-module (guix utils)
|
||||||
#:use-module (guix scripts)
|
#:use-module (guix scripts)
|
||||||
#:use-module (guix import utils)
|
#:use-module (guix import utils)
|
||||||
#:use-module (guix import print)
|
#:use-module (guix import json)
|
||||||
#:use-module (guix scripts import)
|
#:use-module (guix scripts import)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
@ -88,14 +88,8 @@ Import and convert the JSON package definition in PACKAGE-FILE.\n"))
|
|||||||
(reverse opts))))
|
(reverse opts))))
|
||||||
(match args
|
(match args
|
||||||
((file-name)
|
((file-name)
|
||||||
(catch 'json-invalid
|
(or (json->code file-name)
|
||||||
(lambda ()
|
(leave (G_ "invalid JSON in file '~a'~%") file-name)))
|
||||||
(let ((json (json-string->scm
|
|
||||||
(with-input-from-file file-name read-string))))
|
|
||||||
;; TODO: also print define-module boilerplate
|
|
||||||
(package->code (alist->package json))))
|
|
||||||
(lambda _
|
|
||||||
(leave (G_ "invalid JSON in file '~a'~%") file-name))))
|
|
||||||
(()
|
(()
|
||||||
(leave (G_ "too few arguments~%")))
|
(leave (G_ "too few arguments~%")))
|
||||||
((many ...)
|
((many ...)
|
||||||
|
Loading…
Reference in New Issue
Block a user