Skip to content

Add CLI version flag#17

Merged
pipe1os merged 3 commits into
pipe1os:mainfrom
rupayon123:codex/add-version-flag
Jun 13, 2026
Merged

Add CLI version flag#17
pipe1os merged 3 commits into
pipe1os:mainfrom
rupayon123:codex/add-version-flag

Conversation

@rupayon123

Copy link
Copy Markdown
Contributor

Summary

  • Add -v / --version support to the modelinfo CLI using importlib.metadata.version.
  • Fall back to the package version when running directly from source without installed metadata.
  • Add a CLI regression test for the version action.

Validation

  • /Users/rupayonhaldar/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 -m pip install -e .[dev]
  • PYTHONPATH=src /Users/rupayonhaldar/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 -m pytest tests/test_cli.py tests/test_constraints.py
  • /Users/rupayonhaldar/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 -m ruff check src/modelinfo/cli.py tests/test_cli.py

Closes #13

@rupayon123 rupayon123 marked this pull request as ready for review June 13, 2026 04:03
@rupayon123 rupayon123 force-pushed the codex/add-version-flag branch from e77afb6 to a8cdc7d Compare June 13, 2026 04:03
@rupayon123

Copy link
Copy Markdown
Contributor Author

Rebased this onto current main and reran the local checks:

  • python -m pytest — 15 passed
  • python -m ruff check . — passed

The branch is ready for review now.

@pipe1os

pipe1os commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Thank you for your contribution!

the code is good but evaluating package_version()in parse_args()forces importlib.metadata.version to run on every CLI invocation. Since it hits the disk to find package metadata, this adds ~30ms to the startup time.

I pushed a commit replacing the version string evaluation with a custom argparse.Action class. This defers the import and version lookup until the user actually passes the --version flag so the CLI tool remains fast.

@pipe1os pipe1os merged commit 6c08698 into pipe1os:main Jun 13, 2026
9 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.

[Feature]: Add --version flag to the CLI

2 participants