From 6052f7da243e276602eb7f4a53385ec0b0d9f016 Mon Sep 17 00:00:00 2001 From: cage Date: Mon, 18 Mar 2024 19:54:45 +0100 Subject: [PATCH] - updated README to mention that also libjpegturbo and TK must be installed; - [draft] added a function for bash completion. --- README.org | 12 ++- lisp-dependencies | 52 ++++++------ src/command-line.lisp | 179 +++++++++++++++++++++++++----------------- 3 files changed, 143 insertions(+), 100 deletions(-) diff --git a/README.org b/README.org index 355740f..b7f7d7a 100644 --- a/README.org +++ b/README.org @@ -107,6 +107,16 @@ # apt-get install libssl-dev #+END_SRC +*** Indirect foreign dependencies + +These library are not directly required by tinmop, but are needed nevertheless to make the GUI library ([[https://www.autistici.org/interzona/nodgui.html][nodgui]]) works. + + #+BEGIN_SRC sh + # apt-get install tk libturbojpeg0-dev + #+END_SRC + +Note that, at the moment, the ~quick_quicklisp.sh~ script will *not* install the foreign dependencies. + * Install ** Using guix @@ -138,7 +148,7 @@ $ ./configure #+END_SRC - 3. the script ~quick-quicklisp.sh~ will download and install the library manager and the libraries on your home dir. + 3. the script ~quick-quicklisp.sh~ will download and install the library manager and the lisp libraries on your home dir. #+BEGIN_SRC sh $ ./quick_quicklisp.sh diff --git a/lisp-dependencies b/lisp-dependencies index 3e4a509..b28e5b4 100644 --- a/lisp-dependencies +++ b/lisp-dependencies @@ -1,32 +1,32 @@ -alexandria -cl-ppcre-unicode -tooter -croatoan -osicat -cl-spark access +alexandria +babel +bordeaux-threads +cffi +cl-colors2 +cl-html5-parser +cl-i18n +cl-ppcre-unicode +cl-spark +clunit2 +croatoan +crypto-shortcuts +drakma +esrap +ieee-floats +local-time +log4cl +marshal +nodgui +osicat +parse-number +percent-encoding +purgatory sqlite sxql sxql-composer -marshal -bordeaux-threads -log4cl -local-time -cl-colors2 -cl-i18n -clunit2 -esrap -ieee-floats -parse-number -cl-html5-parser -unix-opts -crypto-shortcuts -drakma -usocket -cffi -babel -percent-encoding +tooter trivial-clipboard -purgatory -nodgui +unix-opts +usocket yason diff --git a/src/command-line.lisp b/src/command-line.lisp index da17cc2..78869d5 100644 --- a/src/command-line.lisp +++ b/src/command-line.lisp @@ -22,80 +22,86 @@ (define-constant +start-server-command-line+ #\S :test #'char=) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun options () + `((:name :help + :description (_ "Print help and exit.") + :short #\h + :long "help") + (:name :version + :description (_ "Print program information and exit.") + :short #\v + :long "version") + (:name :folder + :description (_ "Starting folder") + :short #\f + :arg-parser #'identity + :meta-var (_ "FOLDER-NAME") + :long "folder") + (:name :timeline + :description (_ "Starting timeline.") + :short #\t + :meta-var (_ "TIMELINE-NAME") + :arg-parser #'identity + :long "timeline") + (:name :update-timeline + :description (_ "Update timeline.") + :short #\u + :long "update-timeline") + (:name :reset-timeline-pagination + :description (_ "Reset the timeline pagination.") + :short #\R + :long "reset-timeline-pagination") + (:name :check-follows-requests + :description (_ "Check follows requests.") + :short #\c + :long "check-follows-requests") + (:name :execute + :description (_ "Execute script.") + :short #\e + :arg-parser #'identity + :meta-var (_ "SCRIPT-FILE") + :long "execute-script") + (:name :notify-mentions + :description (_ "Notify messages that mentions the user.") + :short #\m + :long "notify-mentions") + (:name :open-net-address + :description (_ "Open net address.") + :short #\o + :arg-parser #'identity + :long "open-net-address") + (:name :gemini-full-screen-mode + :description (_ "Start as gemini client only.") + :short #\G + :long "gemini-client-only") + (:name :gemini-gui + :description (_ "Start as gemini gui client only.") + :short #\U + :long "gemini-gui-client-only") + (:name :gemini-gui-server + :description (_ "Start as gemini gui server only.") + :short +start-server-command-line+ + :long "gemini-gui-server-only") + (:name :load-module + :description (_ "Load a module.") + :short #\M + :meta-var (_ "MODULE-FILE") + :arg-parser #'identity + :long "load-module") + (:name :print-lisp-dependencies + :description (_ "Download lisp libraries (useful for packaging only).") + :short #\X + :long "lisp-dependencies-uris") + (:name :start-dummy-server + :description (_ "Start a dummy sever, just useful for debugging.") + :long "start-dummy-server") + (:name :bash-complete + :description (_ "Complete command line switches (for bash complation only).") + :long "bash-complete")))) + (defmacro gen-opts () - `(opts:define-opts - (:name :help - :description (_ "Print help and exit.") - :short #\h - :long "help") - (:name :version - :description (_ "Print program information and exit.") - :short #\v - :long "version") - (:name :folder - :description (_ "Starting folder") - :short #\f - :arg-parser #'identity - :meta-var (_ "FOLDER-NAME") - :long "folder") - (:name :timeline - :description (_ "Starting timeline.") - :short #\t - :meta-var (_ "TIMELINE-NAME") - :arg-parser #'identity - :long "timeline") - (:name :update-timeline - :description (_ "Update timeline.") - :short #\u - :long "update-timeline") - (:name :reset-timeline-pagination - :description (_ "Reset the timeline pagination.") - :short #\R - :long "reset-timeline-pagination") - (:name :check-follows-requests - :description (_ "Check follows requests.") - :short #\c - :long "check-follows-requests") - (:name :execute - :description (_ "Execute script.") - :short #\e - :arg-parser #'identity - :meta-var (_ "SCRIPT-FILE") - :long "execute-script") - (:name :notify-mentions - :description (_ "Notify messages that mentions the user.") - :short #\m - :long "notify-mentions") - (:name :open-net-address - :description (_ "Open net address.") - :short #\o - :arg-parser #'identity - :long "open-net-address") - (:name :gemini-full-screen-mode - :description (_ "Start as gemini client only.") - :short #\G - :long "gemini-client-only") - (:name :gemini-gui - :description (_ "Start as gemini gui client only.") - :short #\U - :long "gemini-gui-client-only") - (:name :gemini-gui-server - :description (_ "Start as gemini gui server only.") - :short +start-server-command-line+ - :long "gemini-gui-server-only") - (:name :load-module - :description (_ "Load a module.") - :short #\M - :meta-var (_ "MODULE-FILE") - :arg-parser #'identity - :long "load-module") - (:name :print-lisp-dependencies - :description (_ "Download lisp libraries (useful for packaging only).") - :short #\X - :long "lisp-dependencies-uris") - (:name :start-dummy-server - :description (_ "Start a dummy sever, just useful for debugging.") - :long "start-dummy-server"))) + `(opts:define-opts ,@(options))) (defparameter *start-folder* nil) @@ -136,12 +142,39 @@ `(alexandria:when-let ((,option-value (getf ,options ,option-name))) (setf ,option-variable ,option-value)))) +(defun complete () + (let ((options (mapcar (lambda (a) (text-utils:strcat "--" (getf a :long ""))) + (options))) + (words (text-utils:split-words (os-utils:getenv "COMP_WORDS"))) + (words-index (ignore-errors (parse-integer (os-utils:getenv "COMP_CWORD")))) + (command-line (os-utils:getenv "COMP_LINE"))) + (declare (ignore command-line)) + (when (and words + words-index) + (if (< words-index + (length words)) + (let* ((options (mapcar (lambda (a) (text-utils:strcat "--" (getf a :long ""))) + (options))) + (matched (remove-if-not (lambda (a) (cl-ppcre:scan (elt words words-index) + a)) + options))) + (if matched + (write-sequence (text-utils:join-with-strings matched " ") + *standard-output*) + (write-sequence (text-utils:join-with-strings options " ") + *standard-output*))) + (write-sequence (text-utils:join-with-strings options " ") + *standard-output*))))) + (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 :bash-complete) + (complete) + (os-utils:exit-program)) (when (getf options :help) (print-version) (opts:describe :usage-of +program-name+