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.
(queries, keywords, alias)
| 4 | |
| 5 | |
| 6 | def confirm_destructive_query(queries, keywords, alias): |
| 7 | """Check if the query is destructive and prompts the user to confirm. |
| 8 | |
| 9 | Returns: |
| 10 | * None if the query is non-destructive or we can't prompt the user. |
| 11 | * True if the query is destructive and the user wants to proceed. |
| 12 | * False if the query is destructive and the user doesn't want to proceed. |
| 13 | |
| 14 | """ |
| 15 | info = "You're about to run a destructive command" |
| 16 | if alias: |
| 17 | info += f" in {click.style(alias, fg='red')}" |
| 18 | |
| 19 | prompt_text = f"{info}.\nDo you want to proceed?" |
| 20 | if is_destructive(queries, keywords) and sys.stdin.isatty(): |
| 21 | return confirm(prompt_text) |
| 22 | |
| 23 | |
| 24 | def confirm(*args, **kwargs): |