12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- (define-module (guix scripts home edit)
- #:use-module (guix diagnostics)
- #:use-module (guix i18n)
- #:use-module (guix ui)
- #:autoload (guix utils) (string-closest)
- #:use-module (gnu services)
- #:use-module (gnu home services)
- #:use-module (srfi srfi-1)
- #:use-module (ice-9 match)
- #:autoload (guix scripts edit) (spawn-editor)
- #:export (guix-home-edit))
- (define (service-type-not-found type)
- "Report an error about @var{type} not being found and exit."
- (report-error (G_ "~a: no such service type~%") type)
- (let* ((type (symbol->string type))
- (available (fold-home-service-types (lambda (type lst)
- (cons (symbol->string
- (service-type-name type))
- lst))
- '()))
- (closest (string-closest type available)))
- (unless (or (not closest) (string=? closest type))
- (display-hint (G_ "Did you mean @code{~a}?~%")
- closest)))
- (exit 1))
- (define (guix-home-edit . args)
- (when (null? args)
- (leave (G_ "no service types specified, nothing to edit~%")))
- (with-error-handling
- (let* ((types (append-map (lambda (type)
- (let ((type (string->symbol type)))
- (match (lookup-home-service-types type)
- (() (service-type-not-found type))
- ((one) (list one))
- (lst
- (warning (N_ "~a: ~a matching service type~%"
- "~a: ~a matching service types~%"
- (length lst))
- type (length lst))
- lst))))
- args)))
- (spawn-editor (filter-map service-type-location types)))))
|