mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-11-15 17:47:13 +00:00
feat: auto-complete --mount
args
When typing `tutor local run --mount /path/to/edx-pl<TAB>`, the mount option should be auto-completed to the full edx-platform repo path. That is, if shell completion is enabled: https://docs.tutor.overhang.io/install.html#shell-autocompletion Here, we make sure that the implicit form of the `--mount` argument is properly auto-completed. We are unable to get completion to work in the explicit form, because args that include colons do not even reach the `shell_completion` method.
This commit is contained in:
parent
33e4f33afe
commit
f8b5cbc657
@ -18,6 +18,7 @@ Every user-facing change should have an entry in this changelog. Please respect
|
||||
|
||||
## Unreleased
|
||||
|
||||
- [Improvement] Auto-complete implicit `local/dev --mount /path/to/...` options. (by @regisb)
|
||||
- 💥[Feature] Strong typing of action and filter hooks: this allows us to detect incorrect calls to `actions.add` or `filters.add` early. Strong typing forces us to break the `do` and `apply` API by removing the `context` named argument. Developers should replace `do(context=...)` by `do_from_context(..., )` (and similar for `apply`).
|
||||
|
||||
## v14.1.2 (2022-11-02)
|
||||
|
@ -4,6 +4,7 @@ import typing as t
|
||||
from copy import deepcopy
|
||||
|
||||
import click
|
||||
from click.shell_completion import CompletionItem
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from tutor import bindmounts
|
||||
@ -171,6 +172,18 @@ class MountParam(click.ParamType):
|
||||
raise self.fail(f"no mount found for {value}")
|
||||
return mounts
|
||||
|
||||
def shell_complete(
|
||||
self, ctx: click.Context, param: click.Parameter, incomplete: str
|
||||
) -> t.List[CompletionItem]:
|
||||
"""
|
||||
Mount argument completion works only for the single path (implicit) form. The
|
||||
reason is that colons break words in bash completion:
|
||||
http://tiswww.case.edu/php/chet/bash/FAQ (E13)
|
||||
Thus, we do not even attempt to auto-complete mount arguments that include
|
||||
colons: such arguments will not even reach this method.
|
||||
"""
|
||||
return [CompletionItem(incomplete, type="file")]
|
||||
|
||||
|
||||
mount_option = click.option(
|
||||
"-m",
|
||||
|
@ -8,6 +8,7 @@ from __future__ import annotations
|
||||
__license__ = "Apache 2.0"
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
import click
|
||||
|
||||
from tutor.types import Config
|
||||
|
Loading…
Reference in New Issue
Block a user