russell / pcomplete-me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PComplete Me

An attempt to reduce the API of PComplete down to the minimum useful expression of the flags that a program provides.

This project is a WORK IN PROGRESS it’s not working for general usage and still has bugs.

PComplete-Me uses some hacky scripts to export completion data from bash-completion. It doesn’t directly build on it because pcompelete-me is providing extra completion on top of what’s provided by bash-completion and the integration serves to improve maintainability rather than act as a live API.

Widget

PComplete-Me has a concept of completion widgets for providing completion targets, the idea being that the same widget might be shared between multiple CLI tools. Or possibly provide alternative completion for sets of targets.

Lots of the Kubernetes tooling re-defines the way to find configuration, but this duplication can be removed in the pcomplete-me package

test

nix-shell
make test

adding new commands

Configure completion in a test file like `t/pcmpl-tmp-test.sh

source <(argo completion bash)

Then in a new elisp file

;; define a location for the completion file above
(defconst pcmpl-tmp-test-bashinit
  (list
   (format "%s/pcmpl-tmp-test.sh"
           (cond
            (buffer-file-name
             (file-name-directory buffer-file-name))
            (load-file-name
             (file-name-directory load-file-name))))))


;; define a list of all subcommands
(let ((bash-completion-start-files pcmpl-tmp-test-bashinit))
  (defconst tmp-all-subcommands (rs//bash-complete-argo-subcommands "argo")))

;; evaluate this and then cleanup the subcommand tree
(insert tmp-all-subcommands)

(defconst tmp-command-definitions
  (let ((bash-completion-start-files pcmpl-tmp-test-bashinit))
    (mapconcat
     'identity
     (flatten-list
      (rs//subcommand-tree-to-commands
       (cons "cue" argo-all-subcommands) nil (lambda (command) (rs//create-command-definition command pcmpl-cue--global-flags))))
     "\n")))


;; evaluate a line like this to insert the values
(insert tmp-command-definitions)

figuring out flags

(rs//replace-sexp (rs//add-null-completers (rs//group-flags (rs//bash-complete-argo-flags "argo"))))

Known Issues

Errors are not propagated correctly, setting pcmpl-me-debug to t won’t work unless you directly call (pcomplete t) while in an eshell buffer you’ll actually see log output.

About


Languages

Language:Emacs Lisp 95.2%Language:Makefile 4.3%Language:Nix 0.4%Language:Shell 0.1%