From 6012150f3329e43c05032f5f18d05dd6cf79b6ca Mon Sep 17 00:00:00 2001 From: cage Date: Mon, 26 Aug 2024 20:56:29 +0200 Subject: [PATCH] - 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. --- src/command-line.lisp | 10 +++++++++- src/package.lisp | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/command-line.lisp b/src/command-line.lisp index affe4fb..bc34441 100644 --- a/src/command-line.lisp +++ b/src/command-line.lisp @@ -141,6 +141,9 @@ (defparameter *fediverse-account* nil) +(defparameter *free-arguments* nil) + + (defun exit-on-error (e) (format *error-output* "~a~%" e) (os-utils:exit-program 1)) @@ -194,12 +197,17 @@ (values (elt splitted 0) (elt splitted 1)))) +(defun script-arguments () + *free-arguments*) + (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))) + (multiple-value-bind (options free-arguments) + (opts:get-opts) + (setf *free-arguments* free-arguments) (when (getf options :bash-complete) (complete) (os-utils:exit-program)) diff --git a/src/package.lisp b/src/package.lisp index 47ca106..94a2642 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1594,6 +1594,7 @@ (:shadowing-import-from :misc :random-elt :shuffle) (:export :+start-server-command-line+ + :*free-arguments* :*start-folder* :*start-timeline* :*update-timeline* @@ -1610,6 +1611,7 @@ :*rpc-server-mode* :*rpc-client-mode* :fediverse-account-parameters + :script-arguments :manage-opts)) (defpackage :specials