:param config: The configuration object to get the value from :param key: The configuration key to retrieve :type key: str :param prompt_fn: The prompt function to use to prompt the value :param args: Extra arguments for the prompt function :param kwargs: Extra keyword argum
(config, key, prompt_fn, *args, **kwargs)
| 77 | |
| 78 | |
| 79 | def get_or_prompt(config, key, prompt_fn, *args, **kwargs): |
| 80 | """ |
| 81 | :param config: The configuration object to get the value from |
| 82 | :param key: The configuration key to retrieve |
| 83 | :type key: str |
| 84 | :param prompt_fn: The prompt function to use to prompt the value |
| 85 | :param args: Extra arguments for the prompt function |
| 86 | :param kwargs: Extra keyword arguments for hte prompt function |
| 87 | """ |
| 88 | value = config.get(key) |
| 89 | if value is None: |
| 90 | value = prompt_fn(*args, **kwargs) |
| 91 | config.set(key, value) |
| 92 | return value |