feat(08): implement SSOT architecture for network configuration
This commit is contained in:
@@ -60,7 +60,7 @@ def hidden_prompt_func(prompt: str) -> str:
|
||||
def _build_prompt(
|
||||
text: str,
|
||||
suffix: str,
|
||||
show_default: bool = False,
|
||||
show_default: bool | str = False,
|
||||
default: t.Any | None = None,
|
||||
show_choices: bool = True,
|
||||
type: ParamType | None = None,
|
||||
@@ -68,6 +68,8 @@ def _build_prompt(
|
||||
prompt = text
|
||||
if type is not None and show_choices and isinstance(type, Choice):
|
||||
prompt += f" ({', '.join(map(str, type.choices))})"
|
||||
if isinstance(show_default, str):
|
||||
default = f"({show_default})"
|
||||
if default is not None and show_default:
|
||||
prompt = f"{prompt} [{_format_default(default)}]"
|
||||
return f"{prompt}{suffix}"
|
||||
@@ -88,7 +90,7 @@ def prompt(
|
||||
type: ParamType | t.Any | None = None,
|
||||
value_proc: t.Callable[[str], t.Any] | None = None,
|
||||
prompt_suffix: str = ": ",
|
||||
show_default: bool = True,
|
||||
show_default: bool | str = True,
|
||||
err: bool = False,
|
||||
show_choices: bool = True,
|
||||
) -> t.Any:
|
||||
@@ -112,6 +114,8 @@ def prompt(
|
||||
convert a value.
|
||||
:param prompt_suffix: a suffix that should be added to the prompt.
|
||||
:param show_default: shows or hides the default value in the prompt.
|
||||
If this value is a string, it shows that string
|
||||
in parentheses instead of the actual value.
|
||||
:param err: if set to true the file defaults to ``stderr`` instead of
|
||||
``stdout``, the same as with echo.
|
||||
:param show_choices: Show or hide choices if the passed type is a Choice.
|
||||
@@ -119,6 +123,10 @@ def prompt(
|
||||
show_choices is true and text is "Group by" then the
|
||||
prompt will be "Group by (day, week): ".
|
||||
|
||||
.. versionchanged:: 8.3.3
|
||||
``show_default`` can be a string to show a custom value instead
|
||||
of the actual default, matching the help text behavior.
|
||||
|
||||
.. versionchanged:: 8.3.1
|
||||
A space is no longer appended to the prompt.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user