12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- (define-module (guix scripts import json)
- #:use-module (json)
- #:use-module (guix ui)
- #:use-module (guix utils)
- #:use-module (guix scripts)
- #:use-module (guix import utils)
- #:use-module (guix import json)
- #:use-module (guix scripts import)
- #:use-module (guix packages)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-9 gnu)
- #:use-module (srfi srfi-11)
- #:use-module (srfi srfi-37)
- #:use-module (srfi srfi-41)
- #:use-module (ice-9 match)
- #:use-module (ice-9 rdelim)
- #:use-module (ice-9 format)
- #:export (guix-import-json))
- (define %default-options
- '())
- (define (show-help)
- (display (G_ "Usage: guix import json PACKAGE-FILE
- Import and convert the JSON package definition in PACKAGE-FILE.\n"))
- (display (G_ "
- -h, --help display this help and exit"))
- (display (G_ "
- -V, --version display version information and exit"))
- (newline)
- (show-bug-report-information))
- (define %options
-
- (cons* (option '(#\h "help") #f #f
- (lambda args
- (show-help)
- (exit 0)))
- (option '(#\V "version") #f #f
- (lambda args
- (show-version-and-exit "guix import json")))
- %standard-import-options))
- (define (guix-import-json . args)
- (define (parse-options)
-
- (args-fold* args %options
- (lambda (opt name arg result)
- (leave (G_ "~A: unrecognized option~%") name))
- (lambda (arg result)
- (alist-cons 'argument arg result))
- %default-options))
- (let* ((opts (parse-options))
- (args (filter-map (match-lambda
- (('argument . value)
- value)
- (_ #f))
- (reverse opts))))
- (match args
- ((file-name)
- (or (json->code file-name)
- (leave (G_ "invalid JSON in file '~a'~%") file-name)))
- (()
- (leave (G_ "too few arguments~%")))
- ((many ...)
- (leave (G_ "too many arguments~%"))))))
|