mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-04 19:03:39 +00:00
feat: add CONFIG INTERACTIVE action
New hook Action that allows tutor plugins to interact with the configuration at the time of the interactive questionnaire that happens during `tutor local/dev launch`.
This commit is contained in:
parent
c51d02a8af
commit
afb85aaab6
@ -0,0 +1 @@
|
|||||||
|
- [Feature] add `CONFIG_INTERACTIVE` action that allows tutor plugins to interact with the configuration at the time of the interactive questionnaire that happens during tutor local launch. (by @Alec4r).
|
@ -57,6 +57,12 @@ class Actions:
|
|||||||
#: :parameter str name: docker-compose project name.
|
#: :parameter str name: docker-compose project name.
|
||||||
COMPOSE_PROJECT_STARTED: Action[[str, Config, str]] = Action()
|
COMPOSE_PROJECT_STARTED: Action[[str, Config, str]] = Action()
|
||||||
|
|
||||||
|
#: Triggered after all interactive questions have been asked.
|
||||||
|
#: You should use this action if you want to add new questions.
|
||||||
|
#:
|
||||||
|
#: :parameter dict config: project configuration.
|
||||||
|
CONFIG_INTERACTIVE: Action[[Config]] = Action()
|
||||||
|
|
||||||
#: This action is called at the end of the tutor.config.load_full function.
|
#: This action is called at the end of the tutor.config.load_full function.
|
||||||
#: Modifying this object will not trigger changes in the configuration.
|
#: Modifying this object will not trigger changes in the configuration.
|
||||||
#: For all purposes, it should be considered read-only.
|
#: For all purposes, it should be considered read-only.
|
||||||
|
@ -3,7 +3,7 @@ from typing import List, Optional
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
from . import config as tutor_config
|
from . import config as tutor_config
|
||||||
from . import env, exceptions, fmt
|
from . import env, exceptions, fmt, hooks
|
||||||
from .types import Config, get_typed
|
from .types import Config, get_typed
|
||||||
|
|
||||||
|
|
||||||
@ -149,6 +149,8 @@ def ask_questions(config: Config, run_for_prod: Optional[bool] = None) -> None:
|
|||||||
defaults,
|
defaults,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
hooks.Actions.CONFIG_INTERACTIVE.do(config)
|
||||||
|
|
||||||
|
|
||||||
def ask(question: str, key: str, config: Config, defaults: Config) -> None:
|
def ask(question: str, key: str, config: Config, defaults: Config) -> None:
|
||||||
default = get_typed(defaults, key, str)
|
default = get_typed(defaults, key, str)
|
||||||
|
Loading…
Reference in New Issue
Block a user