MCPcopy
hub / github.com/dbcli/pgcli / confirm_destructive_query

Function confirm_destructive_query

pgcli/packages/prompt_utils.py:6–21  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

4
5
6def 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
24def confirm(*args, **kwargs):

Calls 2

is_destructiveFunction · 0.85
confirmFunction · 0.85