MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / prompt_editor_selection

Function prompt_editor_selection

unity_cli/hub/interactive.py:27–63  ·  view source on GitHub ↗

Prompt user to select an editor when required version not installed. Args: required_version: The version required by the project. editors: List of installed editors to choose from. Returns: Selected InstalledEditor, or None if user chose to quit. Also return

(
    required_version: str,
    editors: list[InstalledEditor],
)

Source from the content-addressed store, hash-verified

25
26
27def prompt_editor_selection(
28 required_version: str,
29 editors: list[InstalledEditor],
30) -> InstalledEditor | None:
31 """Prompt user to select an editor when required version not installed.
32
33 Args:
34 required_version: The version required by the project.
35 editors: List of installed editors to choose from.
36
37 Returns:
38 Selected InstalledEditor, or None if user chose to quit.
39 Also returns None if not in TTY or InquirerPy not available.
40 """
41 if not is_tty():
42 return None
43
44 if not _has_inquirerpy():
45 return None
46
47 from InquirerPy import inquirer
48 from InquirerPy.base.control import Choice
49
50 choices: list[Choice] = [
51 Choice(value=None, name="Quit"),
52 ]
53
54 for editor in editors:
55 choices.append(Choice(value=editor, name=f"Use {editor.version}"))
56
57 selected: InstalledEditor | None = inquirer.select(
58 message=f"Unity {required_version} not installed. Choose an action:",
59 choices=choices,
60 default=None,
61 ).execute()
62
63 return selected
64
65
66def prompt_confirm(message: str, default: bool = False) -> bool:

Callers 1

resolve_editorMethod · 0.90

Calls 3

is_ttyFunction · 0.85
_has_inquirerpyFunction · 0.85
executeMethod · 0.80

Tested by

no test coverage detected