shtab icon indicating copy to clipboard operation
shtab copied to clipboard

Function for pattern match file completion

Open mauvilsa opened this issue 3 years ago • 0 comments

The example in https://github.com/iterative/shtab/blob/master/examples/customcomplete.py shows how to implement a completer for *.txt files. The example is good to show how to use custom shell specific functions. However, a completer for files that match a pattern can be considered a very common use case. It would be better to have a simpler way to support it. The shell specific details should be taken care internally by shtab and not burden the users with this. An idea could be something like the following:

parser.add_argument("--image").complete = shtab.file_completer(["*.jpg", "*.png"], ignore_case=True)

mauvilsa avatar Mar 03 '22 08:03 mauvilsa