@@ -60,14 +60,16 @@ def hidden_prompt_func(prompt: str) -> str:
6060def _build_prompt (
6161 text : str ,
6262 suffix : str ,
63- show_default : bool = False ,
63+ show_default : bool | str = False ,
6464 default : t .Any | None = None ,
6565 show_choices : bool = True ,
6666 type : ParamType | None = None ,
6767) -> str :
6868 prompt = text
6969 if type is not None and show_choices and isinstance (type , Choice ):
7070 prompt += f" ({ ', ' .join (map (str , type .choices ))} )"
71+ if isinstance (show_default , str ):
72+ default = f"({ show_default } )"
7173 if default is not None and show_default :
7274 prompt = f"{ prompt } [{ _format_default (default )} ]"
7375 return f"{ prompt } { suffix } "
@@ -88,7 +90,7 @@ def prompt(
8890 type : ParamType | t .Any | None = None ,
8991 value_proc : t .Callable [[str ], t .Any ] | None = None ,
9092 prompt_suffix : str = ": " ,
91- show_default : bool = True ,
93+ show_default : bool | str = True ,
9294 err : bool = False ,
9395 show_choices : bool = True ,
9496) -> t .Any :
@@ -112,6 +114,8 @@ def prompt(
112114 convert a value.
113115 :param prompt_suffix: a suffix that should be added to the prompt.
114116 :param show_default: shows or hides the default value in the prompt.
117+ If this value is a string, it shows that string
118+ in parentheses instead of the actual value.
115119 :param err: if set to true the file defaults to ``stderr`` instead of
116120 ``stdout``, the same as with echo.
117121 :param show_choices: Show or hide choices if the passed type is a Choice.
0 commit comments