Repository navigation
fix(template): exit non-zero on errors and keep --json output pure - #23
rahul05ranjan wants to merge 1 commit into
Conversation
`template create` and `template make` explained their errors on the console and still exited 0: no templates configured, an unknown or cancelled template selection, a project directory that could not be determined, a failed project creation, and an existing template without --force. Each now reports the problem as before and exits with status 1, the convention the other commands already follow. `template list --json` printed the rich "no templates" panel instead of JSON when no library had templates; it now answers with an empty object. The root update notice moves to stderr (new `stderr` flag on `UpdateService.show_update_notification`) so JSON output on stdout stays pure, and the hook script written into new templates no longer prints a second success message next to `template create`'s own. Fixes barisgit#18 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
|
@rahul05ranjan is attempting to deploy a commit to the Paxia LLC Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Hi — Vercel authorization is needed for the preview. Ready for review otherwise! |
What
template createandtemplate makereported their errors on the console and still exited 0, andtemplate list --jsoncould emit non-JSON to stdout (all of #18):create: no templates configured, unknown--template, cancelled selection, undeterminable project directory, and failed project creation all exited 0. They now exit 1.make: the missing-library-path case and "template already exists" without--forceexited 0. They now exit 1 (the no-GitHub-library case already did).template list --jsonwith no templates printed the rich "no templates" panel to stdout instead of JSON. It now prints{}.stderrflag added toUpdateService.show_update_notification), so a JSON stdout stays pure while the notice stays visible in the terminal.create's success message; the print is now a commented example like the rest of the starter hook.Why
Exit code 0 on failure breaks scripts that chain these commands, and a
--jsonmode that can emit a rich panel (or an update panel) to stdout breaks any parser reading the output.Verification
An offline harness ran the real
create/make/list_templatescommand functions (dependencies stubbed) before and after the change, each against an isolated$HOME:create, no templates configuredtyper.Exit(1)create --template missingtyper.Exit(1)create, selection cancelledtyper.Exit(1)make --non-interactiveonto existing templatetyper.Exit(1)_complete_without_promptswith no library pathmakereturns, exit 0typer.Exit(1)list --json, no templates{}(parses as JSON)New CLI tests pin the four reachable cases (
no templates,--template missing, cancelled selection,makeonto an existing template) plus the empty-JSON case, andtest_starting_hook_runsnow asserts the silent starter hook. Docs (commands/template/docs.mdx) document the new exit statuses and the--jsonguarantee.Fixes #18
Summary by CodeRabbit
--force.{}without mixing in a text message.