Repository navigation
fix(cli): --help prints usage; unknown options are refused - #238
Merged
Merged
Conversation
`--help` / `-h` after any command now prints that command's usage and exits 0
without touching the project. Handlers never looked for it, so it ran the
command for real: `generate model --help` wrote a model named `--help`,
`lint --help` installed ruff, `migrate --help` created app.db.
Each registry entry now declares its options ({name: takes_value}), and main()
checks them before any handler runs:
- an unknown option is refused with a did-you-mean (`--feilds` was silently
dropped and the model came out without its fields);
- a value option with no value is refused (`--fields` crashed with a
traceback, `--every` was ignored);
- `--name=value` works as well as `--name value`;
- `test` is not checked: its arguments belong to pytest.
Also:
- `generate` refuses a name that starts with `-`;
- `ai --all` installs every context file as its help says (it opened the menu);
- `help --help` prints the reference (`help` is not option-checked);
- `generate crud <Name> --skip-model` works. `generate model` has always
suggested it, but no generator had the option.
Tests: 96 no-mock subprocess cases; the project tree is hashed before and
after each --help run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
This was referenced Oct 17, 2026
The regression gate flagged _check_options at cyclomatic complexity 13. Same behaviour and messages, in three small functions: _check_options walks the arguments, _option_problem judges one, _unknown_option_message builds the did-you-mean text. `tina4 metrics --path tina4_python --fail-on-regression` passes; tests/test_cli_help_flags.py and test_cli_generate*: 185 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
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.
--helpand-hnow print a command's usage and change nothing, in every framework CLI. Unknown options are refused with a did-you-mean, value options need a value, andai --allworks.This came from
tina4 generate model --help, which made a model called--help. Thetina4client forwards these commands verbatim, so each framework CLI needed the fix. Python is the reference, and the other three are ports with equivalent no-mock tests.What a user will see
generate model --help--help(four files)lint --help/migrate --helpgenerate model Product --feilds name:stringUnknown option --feilds for "generate model". Did you mean --fields?exit 1generate model Product --fieldsOption --fields for "generate model" needs a value: --fields <value>exit 1--fields=price:float--fields price:floatgenerate crud Product --skip-model(the hintgenerate modelprints)help --helpHow it works: each command and generator in the CLI's registry declares the options it accepts (
name -> takes a value). The help and option checks run before any handler, so a refused or--helprun never reaches code that writes. Delegated commands (doctor,setup,deploy) are untouched, because thetina4client answers those.Python specifics (reference)
testisn't option-checked: its arguments go to pytest (test -q -k onestill works).--fieldswith no value crashed withAttributeError: 'bool' object has no attribute 'strip', andai --allopened the menu because the code checked for the bare wordall.Tests
tests/test_cli_help_flags.py: 96 cases. Each runs the realtina4pythonentrypoint as a subprocess in a temp project, and every--helprun hashes the project tree before and after. All 78 original help cases fail on unfixed v3.tests/test_cli*.py: 250 passed, 1 skipped.No failure is new. Firebird connect-timeout and server libcrypto fail on both runs. v3's third failure is
test_cli_serve_debug_env, which flakes on a real server boot (it failed once in seven runs on the branch too).Plan:
plan/cli-help-and-options.md.Parity PRs
tina4client (Termux/iSH,servesetsTINA4_PORT): Install, run and self-update tina4 on Termux (Android) and iSH (iOS) tina4#91🤖 Generated with Claude Code