lisp/_skeleton.lisp @ a9e85b8e5f66

More
author Steve Losh <steve@stevelosh.com>
date Wed, 19 Dec 2018 13:55:03 -0500
parents (none)
children (none)
(ql:quickload '(:adopt))

;;;; Config -------------------------------------------------------------------
(defparameter *default-name* "World")


;;;; Functionality ------------------------------------------------------------
(defun run (name)
  (format t "Hello, ~A~%" name))


;;;; CLI ----------------------------------------------------------------------
(adopt:define-interface *ui* "NAME"
  "Say Hello."
  ((help) "display help and exit"
   :long "help"
   :short #\h
   :reduce (constantly t))
  ((name) (format nil "say hello to NAME (default ~A)" *default-name*)
   :long "name"
   :short #\n
   :parameter "NAME"
   :initial-value *default-name*
   :reduce #'adopt:newest))

(defun toplevel ()
  (multiple-value-bind (arguments options) (adopt:parse-options *ui*)
    (when (gethash 'help options)
      (adopt:print-usage *ui*)
      (adopt:exit 0))
    (unless (null arguments)
      (cerror "Ignore them" "Unrecognized command-line arguments: ~S" arguments))
    (run (gethash 'name options))))