1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2024-12-25 00:00:54 +01:00
tinmop/data/scripts/gemget.lisp
2024-09-28 11:15:12 +02:00

38 lines
1.3 KiB
Common Lisp

;; slurp a gemini url
;; Copyright © 2021 cage
;; 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 <http://www.gnu.org/licenses/>.
;; usage:
;; tinmop -e gemget.lisp -- URL or
;; echo "url" | tinmop -e gemget.lisp
(in-package :scripts)
(defun main ()
(handler-case
(let ((url (or (first command-line:*free-arguments*)
(read-line *standard-input* nil nil nil))))
(write-sequence (gemini-client:slurp-gemini-url url) *standard-output*)
(os-utils:exit-program 0))
(usocket:ns-host-not-found-error (e)
(format *error-output* "~a ~a~%" e (usocket:host-or-ip e))
(os-utils:exit-program 1))
(error (e)
(format *error-output* "~a~%" e)
(os-utils:exit-program 1))))
(main)