Configuration parameter to execute shell commands by default (#246)

This commit is contained in:
konstantin-goldman
2023-05-20 10:10:20 -07:00
committed by GitHub
parent 39b5b18079
commit b8b87e6517
3 changed files with 11 additions and 1 deletions
+2
View File
@@ -286,6 +286,8 @@ DEFAULT_MODEL=gpt-3.5-turbo
DEFAULT_COLOR=magenta
# Force use system role messages (not recommended).
SYSTEM_ROLES=false
# When in --shell mode, default to "Y" for no input.
DEFAULT_EXECUTE_SHELL_CMD=false
```
Possible options for `DEFAULT_COLOR`: black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white.
+8 -1
View File
@@ -175,7 +175,14 @@ def main(
caching=cache,
)
if shell and not stdin_passed and typer.confirm("Execute shell command?"):
if (
shell
and not stdin_passed
and typer.confirm(
text="Execute shell command?",
default=cfg.get("DEFAULT_EXECUTE_SHELL_CMD") == "true",
)
):
run_command(full_completion)
+1
View File
@@ -28,6 +28,7 @@ DEFAULT_CONFIG = {
"DEFAULT_COLOR": os.getenv("DEFAULT_COLOR", "magenta"),
"ROLE_STORAGE_PATH": os.getenv("ROLE_STORAGE_PATH", str(ROLE_STORAGE_PATH)),
"SYSTEM_ROLES": os.getenv("SYSTEM_ROLES", "false"),
"DEFAULT_EXECUTE_SHELL_CMD": os.getenv("DEFAULT_EXECUTE_SHELL_CMD", "false"),
# New features might add their own config variables here.
}