From 1f3a08b080c75b9be7c74235637cce0f91a249d5 Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Wed, 3 Aug 2016 00:39:39 -0700 Subject: [PATCH] Refactor process-action and process-command --- guix/scripts/system.scm | 73 ++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index e2c6b2e..8302d57 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -785,47 +785,46 @@ resulting from command-line parsing." (grub-configuration-device (operating-system-bootloader os))))) - (with-store store - (set-build-options-from-command-line store opts) - - (run-with-store store - (mbegin %store-monad - (set-guile-for-build (default-guile)) - (case action - ((extension-graph) - (export-extension-graph os (current-output-port))) - ((shepherd-graph) - (export-shepherd-graph os (current-output-port))) - (else - (perform-action action os - #:dry-run? dry? - #:derivations-only? (assoc-ref opts - 'derivations-only?) - #:use-substitutes? (assoc-ref opts 'substitutes?) - #:image-size (assoc-ref opts 'image-size) - #:full-boot? (assoc-ref opts 'full-boot?) - #:mappings (filter-map (match-lambda - (('file-system-mapping . m) - m) - (_ #f)) - opts) - #:grub? grub? - #:target target #:device device)))) - #:system system)))) + (case action + ((extension-graph) + (export-extension-graph os (current-output-port))) + ((shepherd-graph) + (export-shepherd-graph os (current-output-port))) + (else + (perform-action action os + #:dry-run? dry? + #:derivations-only? (assoc-ref opts + 'derivations-only?) + #:use-substitutes? (assoc-ref opts 'substitutes?) + #:image-size (assoc-ref opts 'image-size) + #:full-boot? (assoc-ref opts 'full-boot?) + #:mappings (filter-map (match-lambda + (('file-system-mapping . m) + m) + (_ #f)) + opts) + #:grub? grub? + #:target target #:device device))))) (define (process-command command args opts) "Process COMMAND, one of the 'guix system' sub-commands. ARGS is its argument list and OPTS is the option alist." - (case command - ((list-generations) - ;; List generations. No need to connect to the daemon, etc. - (let ((pattern (match args - (() "") - ((pattern) pattern) - (x (leave (_ "wrong number of arguments~%")))))) - (list-generations pattern))) - (else - (process-action command args opts)))) + (with-store store + (set-build-options-from-command-line store opts) + + (run-with-store store + (mbegin %store-monad + (set-guile-for-build (default-guile)) + (case command + ((list-generations) + (let ((pattern (match args + (() "") + ((pattern) pattern) + (x (leave (_ "wrong number of arguments~%")))))) + (list-generations pattern))) + (else + (process-action command args opts)))) + #:system system))) (define (guix-system . args) (define (parse-sub-command arg result) -- 2.7.3