shtab icon indicating copy to clipboard operation
shtab copied to clipboard

idea: do the completion in python code

Open ThomasWaldmann opened this issue 5 months ago • 0 comments

Even with AI help, it is somehow painful to write completion code, e.g. for CLI option values - especially if their spec/type is non-trivial.

Guess shtab's audience is primarily python CLI tool developers who just want to have shell completions, but are not used to or do not like to write shell completion scripts (or preambles with support functions) on their own for N different shells they want to support.

I just had the idea that it might be nice to move that logic to python code (it then would also be independent of the shell), e.g.:

  • we want to complete borg create --compression=X, that option has a type of CompressionSpec
  • some shtab-generated preamble code could call back like borg completion --type=CompressionSpec --value=X
  • the python code in borg would then compute a list of valid completions (starting from X) and output them on stdout
  • the preamble code would use that / present it to the user

ThomasWaldmann avatar Nov 18 '25 20:11 ThomasWaldmann