Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ https://github.com/user-attachments/assets/c2ba7d09-83ea-4d10-a825-92c30f28c0bd

---

### CLI Options

#### `--version`

The `--version` flag allows users to check the installed version of the package directly from the terminal.

Current version: `PromptShell v0.1.1`

## ✨ Features

### 🚀 Redefine Your Terminal Experience
Expand Down
23 changes: 22 additions & 1 deletion promptshell/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,29 @@
from .ansi_support import enable_ansi_support
from .format_utils import format_text, reset_format, get_terminal_size
from .setup import setup_wizard, load_config, get_active_model
from pathlib import Path
import argparse
import toml

# Function to get the version from pyproject.toml
def get_version():
pyproject_path = Path(__file__).parent.parent / "pyproject.toml" # Adjust path if needed
pyproject_data = toml.load(pyproject_path)
return pyproject_data["project"]["version"]

def main():
# Add argument parsing for CLI flags
parser = argparse.ArgumentParser(description="PromptShell CLI")
parser.add_argument("--version", action="store_true", help="Show the version of PromptShell")
args, unknown = parser.parse_known_args() # Allow unknown args for the assistant

# Handle the --version flag
if args.version:
version = get_version()
print(f"PromptShell v{version}")
return

# Load configuration
config = load_config()
if not config:
print("First-time setup required!")
Expand Down Expand Up @@ -61,4 +82,4 @@ def main():
break

if __name__ == "__main__":
main()
main()
Empty file added tests/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import subprocess
import sys

def test_version_flag():
print("Running the command to check the version...")

result = subprocess.run(
[sys.executable, "-m", "promptshell.main", "--version"],
capture_output=True,
text=True
)

if result.returncode == 0:
version_output = result.stdout.strip()
if version_output.startswith("PromptShell v"):
print(f"Version output is as expected: {version_output}")
else:
print("Unexpected output:")
print(version_output)
else:
print(f"Command failed with return code: {result.returncode}")
if result.stderr:
print("Error:", result.stderr)

if __name__ == "__main__":
test_version_flag()