Skip to content

Commit 4af7d04

Browse files
committed
feat(cli): keep codeanalyzer as a deprecated alias for canpy
Re-add the `codeanalyzer` console script for backwards compatibility. It points to a thin shim that prints a one-line deprecation notice to stderr (so piped stdout — e.g. `--emit schema`) stays clean) and then runs the CLI unchanged. To be removed in a future release.
1 parent 3707647 commit 4af7d04

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- **`schema-uml.drawio`** — a clean UML of the `analysis.json` schema (the `PyApplication` containment tree).
2121

2222
### Changed
23-
- **The CLI command is now `canpy`** (was `codeanalyzer`), matching the `cants` (TypeScript) sibling. The PyPI package name is unchanged (`codeanalyzer-python`), as is the importable `codeanalyzer` module.
23+
- **The CLI command is now `canpy`** (was `codeanalyzer`), matching the `cants` (TypeScript) sibling. The PyPI package name is unchanged (`codeanalyzer-python`), as is the importable `codeanalyzer` module. The old `codeanalyzer` command is retained as a **deprecated alias** that prints a notice (to stderr) and then runs unchanged; it will be removed in a future release.
2424
- The README `canpy --help` block is now generated from the live CLI (`scripts/update_readme.py`, between `<!-- BEGIN/END canpy-help -->` markers) so it can't drift from the code.
2525
- The release workflow now installs the `[neo4j]` extra, syncs both the README `--help` block and `schema.neo4j.json` from source before publishing, and uploads the schema contract (`schema.json`) and installer script as GitHub Release assets.
2626

codeanalyzer/__main__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,20 @@ def _write_output(artifacts, output_dir: Path, format: OutputFormat):
229229
pretty_exceptions_show_locals=False,
230230
)
231231

232+
def deprecated_main() -> None:
233+
"""Entry point for the legacy ``codeanalyzer`` command. Prints a one-line
234+
deprecation notice to stderr (so piped stdout — e.g. ``--emit schema`` — stays
235+
clean) and then runs the CLI unchanged. Kept for backwards compatibility; will
236+
be removed in a future release."""
237+
import sys
238+
239+
print(
240+
"codeanalyzer: this command has been renamed to `canpy`. The `codeanalyzer` "
241+
"alias is deprecated and will be removed in a future release — please use `canpy`.",
242+
file=sys.stderr,
243+
)
244+
app()
245+
246+
232247
if __name__ == "__main__":
233248
app()

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ dev = [
6969

7070
[project.scripts]
7171
canpy = "codeanalyzer.__main__:app"
72+
# Deprecated alias kept for backwards compatibility — warns, then delegates to canpy.
73+
codeanalyzer = "codeanalyzer.__main__:deprecated_main"
7274

7375
[build-system]
7476
requires = ["hatchling"]

0 commit comments

Comments
 (0)