2020-09-06 11:32:08 +02:00
|
|
|
;; tinmop: an humble gemini and pleroma client
|
2020-05-08 15:45:43 +02:00
|
|
|
;; Copyright (C) 2020 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/][http://www.gnu.org/licenses/]].
|
|
|
|
|
|
|
|
(in-package :command-line)
|
|
|
|
|
|
|
|
(defun print-version ()
|
|
|
|
(format t (_ "~a version ~a~%") +program-name+ +program-version+))
|
|
|
|
|
|
|
|
(defmacro gen-opts ()
|
|
|
|
`(opts:define-opts
|
|
|
|
(:name :help
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Print help and exit")
|
|
|
|
:short #\h
|
|
|
|
:long "help")
|
2020-05-08 15:45:43 +02:00
|
|
|
(:name :version
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Print program information and exit")
|
|
|
|
:short #\v
|
|
|
|
:long "version")
|
2020-05-08 15:45:43 +02:00
|
|
|
(:name :folder
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Starting folder")
|
|
|
|
:short #\f
|
|
|
|
:arg-parser #'identity
|
|
|
|
:meta-var (_ "FOLDER-NAME")
|
|
|
|
:long "folder")
|
2020-05-08 15:45:43 +02:00
|
|
|
(:name :timeline
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Starting timeline")
|
|
|
|
:short #\t
|
|
|
|
:meta-var (_ "TIMELINE-NAME")
|
|
|
|
:arg-parser #'identity
|
|
|
|
:long "timeline")
|
2020-05-08 15:45:43 +02:00
|
|
|
(:name :update-timeline
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Update timeline")
|
|
|
|
:short #\u
|
2020-05-19 18:37:54 +02:00
|
|
|
:long "update-timeline")
|
2020-05-18 19:16:52 +02:00
|
|
|
(:name :reset-timeline-pagination
|
|
|
|
:description (_ "Reset the timeline pagination")
|
|
|
|
:short #\R
|
|
|
|
:long "reset-timeline-pagination")
|
2020-05-08 15:45:43 +02:00
|
|
|
(:name :check-follows-requests
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Check follows requests")
|
|
|
|
:short #\c
|
|
|
|
:long "check-follows-requests")
|
2020-05-08 15:45:43 +02:00
|
|
|
(:name :execute
|
2020-05-18 19:16:52 +02:00
|
|
|
:description (_ "Execute script")
|
|
|
|
:short #\e
|
|
|
|
:arg-parser #'identity
|
|
|
|
:meta-var (_ "SCRIPT-FILE")
|
2020-05-30 09:53:12 +02:00
|
|
|
:long "execute-script")
|
|
|
|
(:name :notify-mentions
|
|
|
|
:description (_ "Notify messages that mentions the user")
|
|
|
|
:short #\m
|
2020-06-23 15:51:43 +02:00
|
|
|
:long "notify-mentions")
|
|
|
|
(:name :open-gemini-url
|
|
|
|
:description (_ "Open gemini url")
|
|
|
|
:short #\o
|
|
|
|
:arg-parser #'identity
|
|
|
|
:long "open-gemini-url")))
|
2020-05-08 15:45:43 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *start-folder* nil)
|
2020-05-08 15:45:43 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *start-timeline* nil)
|
2020-05-08 15:45:43 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *update-timeline* nil)
|
2020-05-08 15:45:43 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *script-file* nil)
|
2020-05-08 15:45:43 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *check-follow-requests* nil)
|
2020-05-18 19:16:52 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *reset-timeline-pagination* nil)
|
2020-05-08 15:45:43 +02:00
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *notify-mentions* nil)
|
|
|
|
|
2020-06-23 15:51:43 +02:00
|
|
|
(defparameter *gemini-url* nil)
|
|
|
|
|
2020-06-12 18:10:01 +02:00
|
|
|
(defparameter *update-timeline-climb-message-tree* nil)
|
2020-05-30 09:53:12 +02:00
|
|
|
|
2020-05-08 15:45:43 +02:00
|
|
|
(defun exit-on-error (e)
|
|
|
|
(format *error-output* "~a~%" e)
|
|
|
|
(os-utils:exit-program 1))
|
|
|
|
|
|
|
|
(defun manage-opts ()
|
|
|
|
(handler-bind ((opts:unknown-option #'exit-on-error)
|
|
|
|
(opts:missing-arg #'exit-on-error)
|
|
|
|
(opts:missing-required-option #'exit-on-error))
|
|
|
|
(gen-opts)
|
|
|
|
(let ((options (opts:get-opts)))
|
|
|
|
(when (getf options :help)
|
|
|
|
(print-version)
|
2020-07-28 15:58:35 +02:00
|
|
|
(opts:describe :usage-of +program-name+
|
|
|
|
:usage-of-label (_ "Usage")
|
|
|
|
:available-options-label (_ "Available options"))
|
2020-05-08 15:45:43 +02:00
|
|
|
(os-utils:exit-program))
|
|
|
|
(when (getf options :version)
|
|
|
|
(print-version)
|
|
|
|
(os-utils:exit-program))
|
|
|
|
(when (getf options :folder)
|
|
|
|
(setf *start-folder* (getf options :folder)))
|
2020-06-23 15:51:43 +02:00
|
|
|
(when (getf options :open-gemini-url)
|
|
|
|
(setf *gemini-url* (getf options :open-gemini-url)))
|
2020-05-08 15:45:43 +02:00
|
|
|
(when (getf options :timeline)
|
|
|
|
(setf *start-timeline* (getf options :timeline)))
|
2020-05-18 19:16:52 +02:00
|
|
|
(when (getf options :reset-timeline-pagination)
|
|
|
|
(setf *reset-timeline-pagination* t))
|
2020-05-08 15:45:43 +02:00
|
|
|
(when (getf options :update-timeline)
|
2020-05-18 19:16:52 +02:00
|
|
|
(setf *update-timeline* t))
|
2020-05-08 15:45:43 +02:00
|
|
|
(when (getf options :execute)
|
|
|
|
(setf *script-file* (getf options :execute)))
|
|
|
|
(when (getf options :check-follows-requests)
|
2020-05-30 09:53:12 +02:00
|
|
|
(setf *check-follow-requests* (getf options :check-follows-requests)))
|
|
|
|
(when (getf options :notify-mentions)
|
|
|
|
(setf *notify-mentions* (getf options :check-follows-requests))))))
|