mirror of
https://github.com/TheR1D/shell_gpt.git
synced 2026-07-03 14:10:18 +02:00
Show sgpt version command line option (#394)
This commit is contained in:
+1
-1
@@ -60,7 +60,7 @@ dev = [
|
||||
]
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "sgpt/__init__.py"
|
||||
path = "sgpt/__version__.py"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
only-include = ["sgpt"]
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
from .app import main as main
|
||||
from .app import entry_point as cli # noqa: F401
|
||||
|
||||
__version__ = "0.9.4"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
__version__ = "0.9.4"
|
||||
+13
-1
@@ -11,7 +11,12 @@ from sgpt.handlers.chat_handler import ChatHandler
|
||||
from sgpt.handlers.default_handler import DefaultHandler
|
||||
from sgpt.handlers.repl_handler import ReplHandler
|
||||
from sgpt.role import DefaultRoles, SystemRole
|
||||
from sgpt.utils import get_edited_prompt, install_shell_integration, run_command
|
||||
from sgpt.utils import (
|
||||
get_edited_prompt,
|
||||
get_sgpt_version,
|
||||
install_shell_integration,
|
||||
run_command,
|
||||
)
|
||||
|
||||
|
||||
def main(
|
||||
@@ -63,6 +68,13 @@ def main(
|
||||
True,
|
||||
help="Cache completion results.",
|
||||
),
|
||||
version: bool = typer.Option(
|
||||
False,
|
||||
"--version",
|
||||
"-v",
|
||||
help="Show version.",
|
||||
callback=get_sgpt_version,
|
||||
),
|
||||
chat: str = typer.Option(
|
||||
None,
|
||||
help="Follow conversation with id, " 'use "temp" for quick session.',
|
||||
|
||||
@@ -7,6 +7,8 @@ from typing import Any, Callable
|
||||
import typer
|
||||
from click import BadParameter
|
||||
|
||||
from sgpt.__version__ import __version__
|
||||
|
||||
|
||||
def get_edited_prompt() -> str:
|
||||
"""
|
||||
@@ -74,3 +76,11 @@ def install_shell_integration(*_args: Any) -> None:
|
||||
else:
|
||||
url = "https://raw.githubusercontent.com/TheR1D/shell_gpt/shell-integrations/install.sh"
|
||||
os.system(f'sh -c "$(curl -fsSL {url})"')
|
||||
|
||||
|
||||
@option_callback
|
||||
def get_sgpt_version(*_args: Any) -> None:
|
||||
"""
|
||||
Displays the current installed version of ShellGPT
|
||||
"""
|
||||
typer.echo(f"ShellGPT {__version__}")
|
||||
|
||||
@@ -19,6 +19,7 @@ from uuid import uuid4
|
||||
import typer
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from sgpt.__version__ import __version__
|
||||
from sgpt.app import main
|
||||
from sgpt.config import cfg
|
||||
from sgpt.handlers.handler import Handler
|
||||
@@ -454,3 +455,19 @@ class TestShellGpt(TestCase):
|
||||
# Can't really test it since stdin in disable for --shell flag.
|
||||
# for word in ("prints", "hello", "console"):
|
||||
# assert word in result.stdout
|
||||
|
||||
def test_version(self):
|
||||
dict_arguments = {
|
||||
"prompt": "",
|
||||
"--version": True,
|
||||
}
|
||||
result = runner.invoke(app, self.get_arguments(**dict_arguments), input="d\n")
|
||||
assert __version__ in result.stdout
|
||||
|
||||
dict_arguments = {
|
||||
"prompt": "",
|
||||
"-v": True,
|
||||
}
|
||||
|
||||
result = runner.invoke(app, self.get_arguments(**dict_arguments), input="d\n")
|
||||
assert __version__ in result.stdout
|
||||
|
||||
Reference in New Issue
Block a user