;;; guix-command.el --- Popup interface for guix commands -*- lexical-binding: t -*-
-;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
;; This file is part of GNU Guix.
(require 'guix-help-vars)
(require 'guix-read)
(require 'guix-base)
+(require 'guix-build-log)
(require 'guix-guile)
(require 'guix-external)
(guix-command-define-argument-improver
guix-command-improve-action-argument
- '(("graph" :char ?G)
+ '(("container" :char ?C)
+ ("graph" :char ?G)
("environment" :char ?E)
("publish" :char ?u)
("pull" :char ?P)
(defvar guix-command-improve-common-build-argument
'(("--no-substitutes" :char ?s)
("--no-build-hook" :char ?h)
- ("--max-silent-time" :char ?x)))
+ ("--max-silent-time" :char ?x)
+ ("--rounds" :char ?R :fun read-number)
+ ("--with-input" :char ?W)))
(defun guix-command-improve-common-build-argument (argument)
(guix-command-modify-argument-from-alist
(guix-command-define-argument-improver
guix-command-improve-build-argument
'(("--no-grafts" :char ?g)
+ ("--file" :fun guix-read-file-name)
("--root" :fun guix-read-file-name)
("--sources" :char ?S :fun guix-read-source-type :switch? nil)
("--with-source" :fun guix-read-file-name)))
(guix-command-define-argument-improver
guix-command-improve-environment-argument
- '(("--exec" :fun read-shell-command)
+ '(("--ad-hoc"
+ :name "--ad-hoc " :fun guix-read-package-names-string
+ :switch? nil :option? t)
+ ("--expose" :char ?E)
+ ("--share" :char ?S)
("--load" :fun guix-read-file-name)))
(guix-command-define-argument-improver
:switch? nil :option? t)
("--install-from-file" :fun guix-read-file-name)
("--manifest" :fun guix-read-file-name)
+ ("--profile" :fun guix-read-file-name)
("--do-not-upgrade" :char ?U)
("--roll-back" :char ?R)
("--show" :char ?w :fun guix-read-package-name)))
(let ((command (car commands)))
(cond
((member command
- '("archive" "build" "challenge" "edit" "environment"
+ '("archive" "build" "challenge" "edit"
"graph" "lint" "refresh"))
(argument :doc "Packages" :fun 'guix-read-package-names-string))
+ ((equal commands '("container" "exec"))
+ (argument :doc "PID Command [Args...]"))
((string= command "download")
(argument :doc "URL"))
+ ((string= command "environment")
+ (argument :doc "Command [Args...]" :fun 'read-shell-command))
((string= command "gc")
(argument :doc "Paths" :fun 'guix-read-file-name))
((member command '("hash" "system"))
(string= command "import"))
(argument :doc "Package name"))))))
+(defvar guix-command-additional-arguments
+ `((("environment")
+ ,(guix-command-make-argument
+ :name "++packages " :char ?p :option? t
+ :doc "build inputs of the specified packages"
+ :fun 'guix-read-package-names-string)))
+ "Alist of guix commands and additional arguments for them.
+These are 'fake' arguments that are not presented in 'guix' shell
+commands.")
+
(defun guix-command-additional-arguments (&optional commands)
"Return additional arguments for COMMANDS."
(let ((rest-arg (guix-command-rest-argument commands)))
- (and rest-arg (list rest-arg))))
+ (append (guix-assoc-value guix-command-additional-arguments
+ commands)
+ (and rest-arg (list rest-arg)))))
;; Ideally only `guix-command-arguments' function should exist with the
;; contents of `guix-command-all-arguments', but we need to make a
;;; Post processing popup arguments
(defvar guix-command-post-processors
- '(("hash"
+ '(("environment"
+ guix-command-post-process-environment-packages
+ guix-command-post-process-environment-ad-hoc
+ guix-command-post-process-rest-multiple-leave)
+ ("hash"
guix-command-post-process-rest-single)
("package"
guix-command-post-process-package-args)
args (rx string-start (or "--install " "--remove ") (+ any))
:split? t))
+(defun guix-command-post-process-environment-packages (args)
+ "Adjust popup ARGS for specified packages of 'guix environment'
+command."
+ (guix-command-post-process-matching-args
+ args (rx string-start "++packages " (group (+ any)))
+ :group 1
+ :split? t))
+
+(defun guix-command-post-process-environment-ad-hoc (args)
+ "Adjust popup ARGS for '--ad-hoc' argument of 'guix environment'
+command."
+ (guix-command-post-process-matching-args
+ args (rx string-start "--ad-hoc " (+ any))
+ :split? t))
+
(defun guix-command-post-process-args (commands args)
"Adjust popup ARGS for guix COMMANDS."
(let* ((command (car commands))
(("size")
,(guix-command-make-argument
:name "view" :char ?v :doc "View map"))
- (("system" "dmd-graph") ,graph-arg)
+ (("system" "shepherd-graph") ,graph-arg)
(("system" "extension-graph") ,graph-arg)))
"Alist of guix commands and additional 'execute' action arguments.")
("view" . guix-run-view-graph))
(("size")
("view" . guix-run-view-size-map))
- (("system" "dmd-graph")
+ (("system" "shepherd-graph")
("view" . guix-run-view-graph))
(("system" "extension-graph")
("view" . guix-run-view-graph)))
open the log file(s)."
(let* ((args (if (member "--log-file" args)
args
- (apply #'list (car args) "--log-file" (cdr args))))
+ (cl-list* (car args) "--log-file" (cdr args))))
(output (guix-command-output args))
(files (split-string output "\n" t)))
(dolist (file files)
- (guix-find-file-or-url file)
- (guix-build-log-mode))))
+ (guix-build-log-find-file file))))
(defun guix-run-view-graph (args)
"Run 'guix ARGS ...' graph command, make the image and open it."
(map-file (or wished-map-file (guix-png-file-name)))
(args (if wished-map-file
args
- (apply #'list
- (car args)
- (concat "--map-file=" map-file)
- (cdr args)))))
+ (cl-list* (car args)
+ (concat "--map-file=" map-file)
+ (cdr args)))))
(guix-command-output args)
(guix-find-file map-file)))