Check if the query is destructive and prompts the user to confirm. Returns: * None if the query is non-destructive or we can't prompt the user. * True if the query is destructive and the user wants to proceed. * False if the query is destructive and the user doesn't want to proceed.
(keywords: list[str], queries: str)
| 26 | |
| 27 | |
| 28 | def confirm_destructive_query(keywords: list[str], queries: str) -> bool | None: |
| 29 | """Check if the query is destructive and prompts the user to confirm. |
| 30 | |
| 31 | Returns: |
| 32 | * None if the query is non-destructive or we can't prompt the user. |
| 33 | * True if the query is destructive and the user wants to proceed. |
| 34 | * False if the query is destructive and the user doesn't want to proceed. |
| 35 | |
| 36 | """ |
| 37 | prompt_text = "You're about to run a destructive command.\nDo you want to proceed? (y/n)" |
| 38 | if is_destructive(keywords, queries) and sys.stdin.isatty(): |
| 39 | return prompt(prompt_text, type=BOOLEAN_TYPE, err=True) |
| 40 | else: |
| 41 | return None |
| 42 | |
| 43 | |
| 44 | def confirm(*args, **kwargs) -> bool: |
no test coverage detected