--- a/Makefile Mon Jul 01 16:03:23 2019 -0400
+++ b/Makefile Mon Dec 23 15:13:14 2019 -0500
@@ -38,7 +38,7 @@
docs: docs/build/index.html
pubdocs: docs
- hg -R ~/src/sjl.bitbucket.org pull -u
- rsync --delete -a ./docs/build/ ~/src/sjl.bitbucket.org/adopt
- hg -R ~/src/sjl.bitbucket.org commit -Am 'adopt: Update site.'
- hg -R ~/src/sjl.bitbucket.org push
+ hg -R ~/src/docs.stevelosh.com pull -u
+ rsync --delete -a ./docs/build/ ~/src/docs.stevelosh.com/adopt
+ hg -R ~/src/docs.stevelosh.com commit -Am 'adopt: Update site.'
+ hg -R ~/src/docs.stevelosh.com push
--- a/README.markdown Mon Jul 01 16:03:23 2019 -0400
+++ b/README.markdown Mon Dec 23 15:13:14 2019 -0500
@@ -7,8 +7,8 @@
Python's optparse and argparse.
* **License:** MIT
-* **Documentation:** <https://sjl.bitbucket.io/adopt/>
-* **Mercurial:** <https://bitbucket.org/sjl/adopt/>
+* **Documentation:** <https://docs.stevelosh.com/adopt/>
+* **Mercurial:** <https://hg.sr.ht/~sjl/adopt/>
* **Git:** <https://github.com/sjl/adopt/>
Adopt aims to be a simple, robust option parser. It can automatically print
--- a/adopt.asd Mon Jul 01 16:03:23 2019 -0400
+++ b/adopt.asd Mon Dec 23 15:13:14 2019 -0500
@@ -1,7 +1,7 @@
(asdf:defsystem :adopt
:description "Simple, flexible, UNIX-style option parsing."
:author "Steve Losh <steve@stevelosh.com>"
- :homepage "https://sjl.bitbucket.io/adopt/"
+ :homepage "https://docs.stevelosh.com/adopt/"
:license "MIT"
:version "1.0.0"
--- a/docs/01-usage.markdown Mon Jul 01 16:03:23 2019 -0400
+++ b/docs/01-usage.markdown Mon Dec 23 15:13:14 2019 -0500
@@ -114,7 +114,7 @@
have multiple paragraphs in your help text. Once again, `format` is your
friend:
-[Bobbin]: https://sjl.bitbucket.io/bobbin/
+[Bobbin]: https://docs.stevelosh.com/bobbin/
:::lisp
(adopt:define-string *help-text*
--- a/docs/index.markdown Mon Jul 01 16:03:23 2019 -0400
+++ b/docs/index.markdown Mon Dec 23 15:13:14 2019 -0500
@@ -4,8 +4,8 @@
Python's optparse and argparse.
* **License:** MIT
-* **Documentation:** <https://sjl.bitbucket.io/adopt/>
-* **Mercurial:** <https://bitbucket.org/sjl/adopt/>
+* **Documentation:** <https://docs.stevelosh.com/adopt/>
+* **Mercurial:** <https://hg.sr.ht/~sjl/adopt/>
* **Git:** <https://github.com/sjl/adopt/>
Adopt aims to be a simple, robust option parser. It can automatically print
--- a/src/main.lisp Mon Jul 01 16:03:23 2019 -0400
+++ b/src/main.lisp Mon Dec 23 15:13:14 2019 -0500
@@ -104,6 +104,12 @@
:collect `(check-type ,place ,type))))
+(defmacro quit-on-ctrl-c ((&key (code 130)) &body body)
+ `(handler-case
+ (progn ,@body)
+ #+sbcl (sb-sys:interactive-interrupt () (adopt:exit ,code))))
+
+
;;;; Definition ---------------------------------------------------------------
(defclass* option
name
@@ -478,6 +484,24 @@
(cons v remaining))))))))
(recur arguments))))
+(defun parse-options-or-exit (interface &optional (arguments (rest (argv))))
+ "Parse `arguments` according to `interface`, exiting if any error occurs.
+
+ Two values are returned:
+
+ 1. A fresh list of top-level, unaccounted-for arguments that don't correspond
+ to any options defined in `interface`.
+ 2. An `EQL` hash table of option keys to values.
+
+ If an error occurs while parsing the arguments, exits immediately as if with
+ `adopt:print-error-and-exit`.
+
+ See the full documentation for more information.
+
+ "
+ (handler-case (adopt:parse-options ui)
+ (error (c) (adopt:print-error-and-exit c))))
+
;;;; Help ---------------------------------------------------------------------
(defun option-string (option)
@@ -572,7 +596,7 @@
(format stream (bobbin:wrap (help interface) width))
(format stream "~%")
(dolist (group (groups interface))
- (when (options group)
+ (when (or (options group) (help group))
(format stream "~%~A:~%" (or (title group) (name group) "Options"))
(let* ((help (help group))
(help-column 2)
--- a/src/package.lisp Mon Jul 01 16:03:23 2019 -0400
+++ b/src/package.lisp Mon Dec 23 15:13:14 2019 -0500
@@ -8,6 +8,7 @@
:make-interface
:parse-options
+ :parse-options-or-exit
:print-help
:print-help-and-exit