feat: add top-level --version flag to CLI (Closes #1) - #2
Conversation
- Import __version__ from skill2 package in cli.py - Add -V/--version argparse action to build_parser() - Add regression tests for --version and -V flags in test_cli.py - Sync generated Skill runtime bundles via sync_skill_runtime.py
There was a problem hiding this comment.
Code Review
This pull request adds support for the -V and --version flags to the skill2 CLI, allowing users to print the package version. It also updates the CLI parser to explicitly handle help arguments and updates the runtime manifests accordingly. Tests are added to verify the version flags. The review feedback points out that hardcoding the version string '0.1.1' in the tests makes them fragile, and suggests dynamically importing __version__ from the package to ensure the tests remain robust when the version is bumped.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def test_version_flag_prints_version_and_exits_zero(self) -> None: | ||
| result = run_cli("--version") | ||
| self.assertEqual(result.returncode, 0, result.stderr) | ||
| self.assertEqual(result.stdout.strip(), "skill2 0.1.1") | ||
|
|
||
| def test_version_short_flag_prints_version_and_exits_zero(self) -> None: | ||
| result = run_cli("-V") | ||
| self.assertEqual(result.returncode, 0, result.stderr) | ||
| self.assertEqual(result.stdout.strip(), "skill2 0.1.1") |
There was a problem hiding this comment.
Hardcoding the version string '0.1.1' in the tests makes them fragile. If the package version is bumped in 'src/skill2/init.py', these tests will fail. Instead, import 'version' dynamically from the package to ensure the tests remain robust and maintainable.
| def test_version_flag_prints_version_and_exits_zero(self) -> None: | |
| result = run_cli("--version") | |
| self.assertEqual(result.returncode, 0, result.stderr) | |
| self.assertEqual(result.stdout.strip(), "skill2 0.1.1") | |
| def test_version_short_flag_prints_version_and_exits_zero(self) -> None: | |
| result = run_cli("-V") | |
| self.assertEqual(result.returncode, 0, result.stderr) | |
| self.assertEqual(result.stdout.strip(), "skill2 0.1.1") | |
| def test_version_flag_prints_version_and_exits_zero(self) -> None: | |
| from skill2 import __version__ | |
| result = run_cli("--version") | |
| self.assertEqual(result.returncode, 0, result.stderr) | |
| self.assertEqual(result.stdout.strip(), f"skill2 {__version__}") | |
| def test_version_short_flag_prints_version_and_exits_zero(self) -> None: | |
| from skill2 import __version__ | |
| result = run_cli("-V") | |
| self.assertEqual(result.returncode, 0, result.stderr) | |
| self.assertEqual(result.stdout.strip(), f"skill2 {__version__}") |
|
please avoid hard-cord version according to gemini's advice... @gandzekas |
Implements #1 by adding a top-level
--version/-Vflag to the skill2 CLI.Changes:
src/skill2/cli.py: Import__version__from package and register argparseversionactiontests/test_cli.py: Add regression tests for--versionand-Vflagstools/sync_skill_runtime.pyValidation:
Closes #1