Skip to content

Add CLI version option #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025
Merged
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ Taskgist requires a Google AI API key to interact with the Gemini LLM.

Once installed and configured, you can use the `taskgist` CLI. Ensure your virtual environment is activated if you're not using `just run` or `uv run`.

**Check the installed version:**
```bash
taskgist --version
```

**Basic usage with a string input:**
```bash
taskgist "Create a new user authentication system with email verification and password reset capabilities"
Expand Down
7 changes: 7 additions & 0 deletions src/taskgist/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .baml_client.async_client import b as ab # Using async client
from .baml_client.types import KeywordPhrase
from .baml_client.config import set_log_level
from . import __version__

# Load environment variables from .env file at the earliest opportunity
load_dotenv()
Expand Down Expand Up @@ -127,6 +128,12 @@ def main_cli():
description="Generates a concise gist from a software engineering task description using BAML.",
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"-v",
"--version",
action="version",
version=f"%(prog)s {__version__}",
)
parser.add_argument(
"task",
type=str,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import subprocess
import sys
import unittest

import taskgist


class TestVersionCLI(unittest.TestCase):
def test_cli_version(self):
result = subprocess.run(
[sys.executable, "-m", "taskgist.main", "--version"],
capture_output=True,
text=True,
)
self.assertTrue(result.stdout.strip().endswith(taskgist.__version__))
self.assertEqual(result.returncode, 0)


if __name__ == "__main__":
unittest.main()