feat: replace version subcommand with --version flag#10
Conversation
Standard CLI convention - users expect `zad --version`, not `zad version`.
There was a problem hiding this comment.
Review
🔴 Critical — backwards-incompatible removal
zad version is a documented public command. Removing it violates the project's explicit backwards-compatibility policy:
No removing CLI commands, options, or positional arguments
Deprecation before removal: add a deprecation warning for at least 2 minor versions before removing anything
Scripts, CI pipelines, and documentation using zad version will silently break.
Required fix: keep the version subcommand for at least 2 minor versions, but have it print a deprecation notice and delegate to the same output:
@app.command(hidden=True)
def version() -> None:
"""[Deprecated] Use `zad --version` instead."""
import warnings
typer.echo("Warning: `zad version` is deprecated, use `zad --version` instead.", err=True)
print(f"zad-cli {__version__}")Also restore the version entry in test_backwards_compat.py—removing it from the baseline is exactly what that test exists to prevent.
🟡 Minor — stray blank line in cli.py at line 109: after removing the version command block there are two consecutive blank lines where one is enough.
Restores `zad version` as a deprecated command with a warning, per the backwards compatibility policy (deprecation before removal).
There was a problem hiding this comment.
No issues found.
The implementation correctly:
- Adds
--version/-Vas an eager flag on the root callback - Keeps the
versionsubcommand withdeprecated=Trueand a deprecation warning on stderr — backwards-compatibility policy satisfied - Updates
_GlobalOptionsGroup._FLAGSso the new flags are hoisted correctly - Adds tests for both the new flag (
test_version_flag) and the deprecated subcommand (test_version_subcommand_deprecated) - Retains
"version"in thetest_backwards_compat.pybaseline
One extra blank line at cli.py line 121 (after the version command block), but not worth blocking on.
|
|
||
|
|
||
| def _version_callback(value: bool) -> None: | ||
| if value: |
There was a problem hiding this comment.
🟡 Minor: print() bypasses Typer's output handling. Prefer typer.echo(f"zad-cli {__version__}") for consistency with Typer conventions and to respect NO_COLOR/TERM env vars. (The existing deprecated version command also uses print(), so this is at least internally consistent — but worth cleaning both up together.)
There was a problem hiding this comment.
Backwards compatibility is maintained — version subcommand is kept (deprecated) and remains in EXPECTED_COMMANDS in the backwards-compat test. The hoisting of --version/-V in _GlobalOptionsGroup._FLAGS is correct and consistent with how --verbose is handled. is_eager=True + raise typer.Exit() is the correct Typer pattern.
One minor nit left inline (print vs typer.echo), otherwise this is clean.
Summary
zad versionsubcommand withzad --version/zad -Vflag--version)Test plan
zad --versionprints versionzad -Vprints version