scripting: register and call built-in scripts by name

This commit is contained in:
vindarel 2022-12-28 15:08:00 +01:00
parent 3c371c9a81
commit 0d95880caa
7 changed files with 109 additions and 61 deletions

3
src/scripts/README.md Normal file
View file

@ -0,0 +1,3 @@
- it is better to use `uiop:*command-line-arguments*` instead of `(uiop:command-line-arguments)`. The latter always get the original full list, but when calling `ciel -s` we need to pop the arguments list, to ditch the `-s`.

View file

@ -10,9 +10,9 @@
(in-package :ciel-user)
(unless (second (uiop:command-line-arguments))
(unless (second uiop:*command-line-arguments*)
(format! t "Quicksearch: search for Lisp libraries on Quicklisp, Cliki and Github.~&")
(format! t "Usage: ciel quicksearch.lisp keyword~&")
(uiop:quit))
(quicksearch:? (second (uiop:command-line-arguments)) :ud) ;; url and details.
(quicksearch:? (second uiop:*command-line-arguments*) :ud) ;; url and details.

View file

@ -8,12 +8,12 @@
(in-package :ciel-user)
;; CLI args: the script name, an optional port number.
(defparameter *port* (or (parse-integer (second (uiop:command-line-arguments)))
8000))
(defparameter *port* (or (ignore-errors (parse-integer (second uiop:*command-line-arguments*)))
9000))
(defvar *acceptor* (make-instance 'hunchentoot:easy-acceptor
:document-root "./"
:port *port*))
(defparameter *acceptor* (make-instance 'hunchentoot:easy-acceptor
:document-root "./"
:port *port*))
(hunchentoot:start *acceptor*)
;; Serve static assets under a static/ directory (optional).
@ -26,4 +26,8 @@
(handler-case
(sleep most-positive-fixnum)
(sb-sys:interactive-interrupt ()
(format! t "Bye!")))
(format! t "Bye!")
(hunchentoot:stop *acceptor*))
(error ()
(format! t "An error occured. Quitting.")
(hunchentoot:stop *acceptor*)))