Prompt the user to provide a dictionary of data. :param var_name: Variable as specified in the context :param default_value: Value that will be returned if no input is provided :return: A Python dictionary to use in the context.
(var_name: str, default_value, prompts=None, prefix: str = "")
| 172 | |
| 173 | |
| 174 | def read_user_dict(var_name: str, default_value, prompts=None, prefix: str = ""): |
| 175 | """Prompt the user to provide a dictionary of data. |
| 176 | |
| 177 | :param var_name: Variable as specified in the context |
| 178 | :param default_value: Value that will be returned if no input is provided |
| 179 | :return: A Python dictionary to use in the context. |
| 180 | """ |
| 181 | if not isinstance(default_value, dict): |
| 182 | raise TypeError |
| 183 | |
| 184 | question = ( |
| 185 | prompts[var_name] |
| 186 | if prompts and var_name in prompts and prompts[var_name] |
| 187 | else var_name |
| 188 | ) |
| 189 | return JsonPrompt.ask( |
| 190 | f"{prefix}{question} [cyan bold]({DEFAULT_DISPLAY})[/]", |
| 191 | default=default_value, |
| 192 | show_default=False, |
| 193 | ) |
| 194 | |
| 195 | |
| 196 | _Raw: TypeAlias = bool | dict["_Raw", "_Raw"] | list["_Raw"] | str | None |
no outgoing calls
searching dependent graphs…