mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-21 08:50:51 +01:00
- added short options to bash complations.
This commit is contained in:
parent
fc31ba5ac7
commit
6a156c9bbd
@ -81,7 +81,7 @@
|
|||||||
:long "gemini-gui-client-only")
|
:long "gemini-gui-client-only")
|
||||||
(:name :gemini-gui-server
|
(:name :gemini-gui-server
|
||||||
:description (_ "Start as gemini gui server only.")
|
:description (_ "Start as gemini gui server only.")
|
||||||
:short +start-server-command-line+
|
:short ,+start-server-command-line+
|
||||||
:long "gemini-gui-server-only")
|
:long "gemini-gui-server-only")
|
||||||
(:name :load-module
|
(:name :load-module
|
||||||
:description (_ "Load a module.")
|
:description (_ "Load a module.")
|
||||||
@ -143,28 +143,39 @@
|
|||||||
(setf ,option-variable ,option-value))))
|
(setf ,option-variable ,option-value))))
|
||||||
|
|
||||||
(defun complete ()
|
(defun complete ()
|
||||||
(let ((options (mapcar (lambda (a) (text-utils:strcat "--" (getf a :long "")))
|
(flet ((write-shell-array (sequence)
|
||||||
(options)))
|
(write-sequence (text-utils:join-with-strings sequence " ")
|
||||||
(words (text-utils:split-words (os-utils:getenv "COMP_WORDS")))
|
*standard-output*))
|
||||||
(words-index (ignore-errors (parse-integer (os-utils:getenv "COMP_CWORD"))))
|
(build-options (all-options switch-prefix key)
|
||||||
(command-line (os-utils:getenv "COMP_LINE")))
|
(remove-if (lambda (a) (string= a switch-prefix))
|
||||||
(declare (ignore command-line))
|
(mapcar (lambda (a) (format nil
|
||||||
(when (and words
|
"~a~a"
|
||||||
words-index)
|
switch-prefix
|
||||||
(if (< words-index
|
(getf a key "")))
|
||||||
(length words))
|
all-options))))
|
||||||
(let* ((options (mapcar (lambda (a) (text-utils:strcat "--" (getf a :long "")))
|
(let* ((all-options (options))
|
||||||
(options)))
|
(long-options (build-options all-options "--" :long))
|
||||||
(matched (remove-if-not (lambda (a) (cl-ppcre:scan (elt words words-index)
|
(short-options (build-options all-options "-" :short))
|
||||||
a))
|
(options (nconc long-options short-options))
|
||||||
options)))
|
(words (text-utils:split-words (os-utils:getenv "COMP_WORDS")))
|
||||||
(if matched
|
(words-index (ignore-errors (parse-integer (os-utils:getenv "COMP_CWORD"))))
|
||||||
(write-sequence (text-utils:join-with-strings matched " ")
|
(command-line (os-utils:getenv "COMP_LINE")))
|
||||||
*standard-output*)
|
(declare (ignore command-line))
|
||||||
(write-sequence (text-utils:join-with-strings options " ")
|
(when (and words
|
||||||
*standard-output*)))
|
words-index)
|
||||||
(write-sequence (text-utils:join-with-strings options " ")
|
(if (< words-index
|
||||||
*standard-output*)))))
|
(length words))
|
||||||
|
(let ((matched (sort (remove-if-not (lambda (a)
|
||||||
|
(cl-ppcre:scan (strcat "^"
|
||||||
|
(elt words words-index))
|
||||||
|
a))
|
||||||
|
options)
|
||||||
|
(lambda (a b) (< (length a) (length b))))))
|
||||||
|
(if matched
|
||||||
|
(progn
|
||||||
|
(write-shell-array matched))
|
||||||
|
(write-shell-array options)))
|
||||||
|
(write-shell-array options))))))
|
||||||
|
|
||||||
(defun manage-opts ()
|
(defun manage-opts ()
|
||||||
(handler-bind ((opts:unknown-option #'exit-on-error)
|
(handler-bind ((opts:unknown-option #'exit-on-error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user