1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-02-16 08:00:35 +01:00

- added code to allow scripts to gets their command line switches

those switches (if any) after the "--" are returned by function "script-arguments"
  and can be used by scripts.
This commit is contained in:
cage 2024-08-26 20:56:29 +02:00
parent 51cc86cf42
commit 6012150f33
2 changed files with 11 additions and 1 deletions

View File

@ -141,6 +141,9 @@
(defparameter *fediverse-account* nil) (defparameter *fediverse-account* nil)
(defparameter *free-arguments* nil)
(defun exit-on-error (e) (defun exit-on-error (e)
(format *error-output* "~a~%" e) (format *error-output* "~a~%" e)
(os-utils:exit-program 1)) (os-utils:exit-program 1))
@ -194,12 +197,17 @@
(values (elt splitted 0) (values (elt splitted 0)
(elt splitted 1)))) (elt splitted 1))))
(defun script-arguments ()
*free-arguments*)
(defun manage-opts () (defun manage-opts ()
(handler-bind ((opts:unknown-option #'exit-on-error) (handler-bind ((opts:unknown-option #'exit-on-error)
(opts:missing-arg #'exit-on-error) (opts:missing-arg #'exit-on-error)
(opts:missing-required-option #'exit-on-error)) (opts:missing-required-option #'exit-on-error))
(gen-opts) (gen-opts)
(let ((options (opts:get-opts))) (multiple-value-bind (options free-arguments)
(opts:get-opts)
(setf *free-arguments* free-arguments)
(when (getf options :bash-complete) (when (getf options :bash-complete)
(complete) (complete)
(os-utils:exit-program)) (os-utils:exit-program))

View File

@ -1594,6 +1594,7 @@
(:shadowing-import-from :misc :random-elt :shuffle) (:shadowing-import-from :misc :random-elt :shuffle)
(:export (:export
:+start-server-command-line+ :+start-server-command-line+
:*free-arguments*
:*start-folder* :*start-folder*
:*start-timeline* :*start-timeline*
:*update-timeline* :*update-timeline*
@ -1610,6 +1611,7 @@
:*rpc-server-mode* :*rpc-server-mode*
:*rpc-client-mode* :*rpc-client-mode*
:fediverse-account-parameters :fediverse-account-parameters
:script-arguments
:manage-opts)) :manage-opts))
(defpackage :specials (defpackage :specials