fix #409: add a else case to report unknown command clearly to the usr#412
Open
pepedinho wants to merge 1 commit intozenc-lang:mainfrom
Open
fix #409: add a else case to report unknown command clearly to the usr#412pepedinho wants to merge 1 commit intozenc-lang:mainfrom
pepedinho wants to merge 1 commit intozenc-lang:mainfrom
Conversation
bf34684 to
1a09c1c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the zc CLI command parsing to explicitly reject unknown subcommands (e.g., zc test ...) instead of silently falling back to the default compile flow, addressing issue #409.
Changes:
- Add an explicit
elsebranch inmaincommand parsing to detect unknown commands. - Print a clear error message, show usage, and exit with a non-zero status for unknown commands.
Comment on lines
+188
to
+194
| else | ||
| { | ||
| fprintf(stderr, COLOR_BOLD COLOR_RED "error" COLOR_RESET ": unknown command '%s'\n", | ||
| command); | ||
| print_usage(); | ||
| return 1; | ||
| } |
There was a problem hiding this comment.
This change fixes a CLI parsing bug, but there doesn’t appear to be an automated regression test that asserts zc <unknown> exits non-zero and reports the unknown command. Adding a small integration test (e.g., in tests/scripts/ or similar harness) would help prevent this from regressing again.
Contributor
Author
There was a problem hiding this comment.
I'm not sure where I should write this test; should I create a new script for it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I just add a check in the else branch of argument parsing to catch unknown commands,
This changes fixes #409
before:
after:
Type of change
Checklist: