From a015d78e7598bf462307d05a9e37c8ceacba8fb4 Mon Sep 17 00:00:00 2001 From: Luis-Leao-rbcx Date: Wed, 11 Jun 2025 14:43:32 +0100 Subject: [PATCH 1/3] Add Table of Contents to README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 7966933..69db95f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,18 @@ https://github.com/user-attachments/assets/c2ba7d09-83ea-4d10-a825-92c30f28c0bd --- +## Table of Contents + +- [✨ Features](#-features) +- [📥 Installation](#-installation) +- [⚙️ Configuration](#️-configuration) +- [🛠 Usage](#-usage) +- [🌟 Examples](#-examples) +- [🚧 Development Status](#-development-status) +- [🤝 Contributing](#-contributing) +- [📜 License](#-license) +- [📧 Contact](#-contact) + ## ✨ Features ### 🚀 Redefine Your Terminal Experience From f46853e7d1117c3095728f2d08952200f13fa507 Mon Sep 17 00:00:00 2001 From: Luis-Leao-rbcx Date: Wed, 11 Jun 2025 17:02:20 +0100 Subject: [PATCH 2/3] I edited the main.py to support the --version flag. And added a test for the version --- README.md | 8 ++++++++ promptshell/main.py | 23 ++++++++++++++++++++++- tests/__init__.py | 0 tests/test_version.py | 26 ++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/__init__.py create mode 100644 tests/test_version.py diff --git a/README.md b/README.md index 69db95f..3d7f5be 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ https://github.com/user-attachments/assets/c2ba7d09-83ea-4d10-a825-92c30f28c0bd - [📜 License](#-license) - [📧 Contact](#-contact) +### 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 diff --git a/promptshell/main.py b/promptshell/main.py index a8dfb90..2096b5c 100644 --- a/promptshell/main.py +++ b/promptshell/main.py @@ -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!") @@ -61,4 +82,4 @@ def main(): break if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..1e673b7 --- /dev/null +++ b/tests/test_version.py @@ -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() From 42fe703f60edc731ca6122da7b665e489265843c Mon Sep 17 00:00:00 2001 From: Luis-Leao-rbcx Date: Wed, 11 Jun 2025 17:06:59 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/README.md b/README.md index 3d7f5be..2f1beb3 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,6 @@ https://github.com/user-attachments/assets/c2ba7d09-83ea-4d10-a825-92c30f28c0bd --- -## Table of Contents - -- [✨ Features](#-features) -- [📥 Installation](#-installation) -- [⚙️ Configuration](#️-configuration) -- [🛠 Usage](#-usage) -- [🌟 Examples](#-examples) -- [🚧 Development Status](#-development-status) -- [🤝 Contributing](#-contributing) -- [📜 License](#-license) -- [📧 Contact](#-contact) - ### CLI Options #### `--version`