MCPcopy Index your code
hub / github.com/dbcli/mycli / confirm_destructive_query

Function confirm_destructive_query

mycli/packages/interactive_utils.py:28–41  ·  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.

(keywords: list[str], queries: str)

Source from the content-addressed store, hash-verified

26
27
28def 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
44def confirm(*args, **kwargs) -> bool:

Callers 5

execute_from_fileMethod · 0.90
watch_queryFunction · 0.90
main_execute_from_cliFunction · 0.90
_one_iterationFunction · 0.90

Calls 3

is_destructiveFunction · 0.90
promptFunction · 0.85
isattyMethod · 0.80

Tested by

no test coverage detected