Skip to content

fix: add --version flag to CLI#13

Merged
kiyeonjeon21 merged 1 commit intovericontext:mainfrom
abhijeetnardele24-hash:fix-version-flag
Apr 2, 2026
Merged

fix: add --version flag to CLI#13
kiyeonjeon21 merged 1 commit intovericontext:mainfrom
abhijeetnardele24-hash:fix-version-flag

Conversation

@abhijeetnardele24-hash
Copy link
Copy Markdown
Contributor

Adds a global --version flag using a Typer callback while keeping the existing version subcommand. Also adds CLI tests for both entrypoints.

Closes #3

Signed-off-by: abhijeet nardele <234410808+abhijeetnardele24-hash@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 17:01
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

@abhijeetnardele24-hash is attempting to deploy a commit to the Kiyeon Jeon's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a global --version flag to the parsemux Typer CLI (while keeping the existing version subcommand), and introduces CLI tests to verify both entrypoints output the expected version string.

Changes:

  • Add an eager --version option via @app.callback() and centralize version printing in _print_version().
  • Reuse _print_version() in the existing version subcommand to keep output consistent.
  • Add CLI tests covering parsemux version and parsemux --version.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/parsemux/cli/main.py Adds global --version handling via Typer callback and refactors version printing into a helper.
tests/test_cli.py Adds tests asserting both the version command and --version flag print parsemux {__version__}.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +33 to +37
def _version_callback(value: bool) -> None:
"""Handle the global --version flag."""
if value:
_print_version()
raise typer.Exit()
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _version_callback is annotated/used like it returns None, but Click/Typer callbacks can replace the option value with the callback’s return. When --version is not provided, this callback currently returns None, which can cause the version parameter in main() (typed as bool) to receive None at runtime. Consider either returning value from the callback (and annotating it accordingly), or changing the option to Optional[bool] = typer.Option(None, ...) (Typer’s common pattern for eager version flags).

Suggested change
def _version_callback(value: bool) -> None:
"""Handle the global --version flag."""
if value:
_print_version()
raise typer.Exit()
def _version_callback(value: bool) -> bool:
"""Handle the global --version flag."""
if value:
_print_version()
raise typer.Exit()
return value

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +4
from typer.testing import CliRunner

from parsemux import __version__
from parsemux.cli.main import app
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new test file doesn’t follow the existing tests’ module header convention (module docstring + from __future__ import annotations). For consistency with the rest of the suite (e.g., tests/test_api.py:1-4, tests/test_router.py:1-4), consider adding those at the top of this file as well.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@kiyeonjeon21 kiyeonjeon21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Clean implementation.

  • is_eager=True callback pattern is the correct Typer approach
  • Good refactor extracting _print_version() to share with the subcommand
  • Tests cover both --version and version subcommand

Merging. Thanks for the first contribution @abhijeetnardele24-hash!

@kiyeonjeon21 kiyeonjeon21 merged commit 11959a4 into vericontext:main Apr 2, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --version flag to CLI

3 participants