mirror of
https://github.com/TheR1D/shell_gpt.git
synced 2026-07-03 14:10:18 +02:00
Implement modify option for generated shell command (#566)
Co-authored-by: Farkhod Sadykov <farkhod.sadykov@gmail.com>
This commit is contained in:
@@ -31,6 +31,7 @@ dependencies = [
|
||||
"distro >= 1.8.0, < 2.0.0",
|
||||
"instructor >= 1.0.0, < 2.0.0",
|
||||
'pyreadline3 >= 3.4.1, < 4.0.0; sys_platform == "win32"',
|
||||
"prompt_toolkit >= 3.0.51",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
+8
-2
@@ -7,6 +7,7 @@ import sys
|
||||
import typer
|
||||
from click import BadArgumentUsage
|
||||
from click.types import Choice
|
||||
from prompt_toolkit import PromptSession
|
||||
|
||||
from sgpt.config import cfg
|
||||
from sgpt.function import get_openai_schemas
|
||||
@@ -237,10 +238,12 @@ def main(
|
||||
functions=function_schemas,
|
||||
)
|
||||
|
||||
session = PromptSession()
|
||||
|
||||
while shell and interaction:
|
||||
option = typer.prompt(
|
||||
text="[E]xecute, [D]escribe, [A]bort",
|
||||
type=Choice(("e", "d", "a", "y"), case_sensitive=False),
|
||||
text="[E]xecute, [M]odify, [D]escribe, [A]bort",
|
||||
type=Choice(("e", "m", "d", "a", "y"), case_sensitive=False),
|
||||
default="e" if cfg.get("DEFAULT_EXECUTE_SHELL_CMD") == "true" else "a",
|
||||
show_choices=False,
|
||||
show_default=False,
|
||||
@@ -248,6 +251,9 @@ def main(
|
||||
if option in ("e", "y"):
|
||||
# "y" option is for keeping compatibility with old version.
|
||||
run_command(full_completion)
|
||||
elif option == "m":
|
||||
full_completion = session.prompt('', default=full_completion)
|
||||
continue
|
||||
elif option == "d":
|
||||
DefaultHandler(DefaultRoles.DESCRIBE_SHELL.get_role(), md).handle(
|
||||
full_completion,
|
||||
|
||||
Reference in New Issue
Block a user