Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.9 KiB

  1. ;;; docker-process.el --- Emacs interface to Docker -*- lexical-binding: t -*-
  2. ;; Author: Philippe Vaucher <philippe.vaucher@gmail.com>
  3. ;; This file is NOT part of GNU Emacs.
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation; either version 3, or (at your option)
  7. ;; any later version.
  8. ;;
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  16. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. ;; Boston, MA 02110-1301, USA.
  18. ;;; Commentary:
  19. ;;; Code:
  20. (require 's)
  21. (require 'dash)
  22. (require 'docker-group)
  23. (defcustom docker-command "docker"
  24. "The docker (or podman) binary."
  25. :group 'docker
  26. :type 'string)
  27. (defcustom docker-arguments '()
  28. "Default arguments for `docker'."
  29. :group 'docker
  30. :type '(repeat (string :tag "Argument")))
  31. (defcustom docker-run-as-root nil
  32. "Run docker as root."
  33. :group 'docker
  34. :type 'boolean)
  35. (defun docker-run (action &rest args)
  36. "Execute \"docker ACTION\" using ARGS."
  37. (let ((default-directory (if (and docker-run-as-root (not (file-remote-p default-directory))) "/sudo::" default-directory)))
  38. (let ((command (format "%s %s %s %s"
  39. docker-command
  40. (s-join " " docker-arguments)
  41. action
  42. (s-join " " (-flatten (-non-nil args))))))
  43. (message command)
  44. (shell-command-to-string command))))
  45. (provide 'docker-process)
  46. ;;; docker-process.el ends here