Task Autocompletion

Tasks already have some autocompletion built in, such as for flags and arguments.

Autocompletion can also be enabled for individual parameters by passing the completer argument to the arg decorator.

from quickie import Arg, task
from quickie.completion import PathCompleter

@task(args=[
    Arg("--path", help="A path", completer=PathCompleter()),
])
def some_task(path):
    print(f"Path: {path}")

The PathCompleter accepts an optional wd parameter to control which directory paths are resolved relative to, following the same rules as task working directories:

# Resolve relative to the tasks module parent directory
Arg("--path", completer=PathCompleter(wd="."))
Arg("--path", completer=PathCompleter(wd="./subdir"))

# Resolve relative to a specific absolute directory
Arg("--path", completer=PathCompleter(wd="/absolute/path"))

# Resolve relative to the current working directory (default)
Arg("--path", completer=PathCompleter())
Arg("--path", completer=PathCompleter(wd="relative/to/cwd"))

When wd is None (the default), completion resolves relative to the current working directory, preserving the existing behaviour.

Some completers are provided by Quickie, such as quickie.completion.PathCompleter and quickie.completion.python.PytestCompleter. You can also create your own completers by subclassing quickie.completion.base.BaseCompleter and implementing the quickie.completion.base.BaseCompleter.complete() method.