-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple-httpd-cli.el
More file actions
72 lines (59 loc) · 2.42 KB
/
simple-httpd-cli.el
File metadata and controls
72 lines (59 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;;; simple-httpd-cli.el --- A command-line interface for simple-httpd -*- lexical-binding: t; -*-
;; Copyright (C) 2026 JenChieh
;; Author: JenChieh <jcs090218@gmail.com>
;; Maintainer: JenChieh <jcs090218@gmail.com>
;; URL: https://github.com/emacs-eine/simple-httpd-cli
;; Version: 1.0.0
;; Package-Requires: ((emacs "26.1")
;; (simple-httpd "1.5.1")
;; (commander "0.7.0")
;; (msgu "0.1.0"))
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; A command-line interface for simple-httpd
;;
;;; Code:
(require 'simple-httpd)
(require 'msgu)
(defgroup simple-httpd-cli nil
"A command-line interface for simple-httpd."
:prefix "simple-httpd-cli-"
:group 'tool
:link '(url-link :tag "Repository" "https://github.com/emacs-eine/simple-httpd-cli"))
(defun simple-httpd-cli--version ()
"Return the verions of the package `simple-httpd'."
(package-activate-all)
(package-version-join
(package-desc-version (car (alist-get 'simple-httpd package-alist)))))
;;;###autoload
(defun simple-httpd-cli-start (root &optional host port ip-family)
"Start the http server."
(let* ((httpd-root (or root default-directory httpd-root))
(httpd-host (or host httpd-host))
(httpd-port (or port httpd-port))
(httpd-ip-family (or ip-family httpd-ip-family)))
(message "Starting up http-server, serving `%s'" (expand-file-name httpd-root))
(message "")
(message "simple-httpd version: %s" (simple-httpd-cli--version))
(message "")
(message "Available on:")
(message " %s:%s" httpd-host httpd-port)
(message "")
(message "Hit CTRL-C to stop the server")
(httpd-start)
;; Run forever.
(while t (sit-for 0.1))))
(provide 'simple-httpd-cli)
;;; simple-httpd-cli.el ends here