Repository navigation
fix(cli): --help prints usage; unknown options are refused - #140
Merged
Merged
Conversation
`--help` / `-h` after any command now prints that command's usage and exits 0
without touching the project. Most handlers never looked for it, so it ran the
command for real: `generate model -h` wrote a model named `-h`, `generate auth
--help` wrote the auth scaffold, `lint --help` ran `bundle add rubocop`,
`migrate:status --help` booted the app. OptionParser commands printed their
own banner; every command now prints one format. `serve` / `start` keep `-h`
as --host, so `-h 127.0.0.1` still works; `--help` is help everywhere.
`help --help` prints the full reference (help is not option-checked).
Each registry entry now declares its options ({name => takes_value}, plus
OptionParser short aliases), and #run checks them before any handler runs:
- an unknown option is refused with a did-you-mean (`--feilds` was silently
dropped; `queue work --onse` polled forever);
- a value option with no value is refused (`serve --port` raised
OptionParser::MissingArgument, `--every` was ignored), and an OptionParser
error such as `--port abc` no longer prints a backtrace;
- `--name=value` works as well as `--name value`.
Also: `generate` refuses a name that starts with `-`; `generate crud
--skip-model` is implemented (`generate model` suggests it); `ai --all` works
(it crashed: ai.rb never loaded Tina4::VERSION) and `ai all` too.
Tests: 106 no-mock cases running the real exe/tina4ruby; the project tree is
hashed before and after each --help run. Ruby port of tina4-python
fix/cli-help-flags.
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
`tina4 metrics --fail-on-regression` flagged check_options (cyclomatic complexity 14; cli.rb offenders 6 -> 7). Split it the way the Python reference did: check_options walks argv, option_problem(argv, i, accepted, short, label) judges one argument and returns [message, consumed], option_name reads the long name from `--name`, `--name=value`, `-p` or `-p7147`, and unknown_option_message builds the did-you-mean text. Behaviour and messages are unchanged. Gate: offenders 277 -> 277, exit 0. spec/cli_help_flags_spec.rb 106/106, CLI specs 292 examples, 0 failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
`tina4ruby --help` read `Usage: tina4ruby COMMAND [options]`, and its footer `Run 'tina4ruby COMMAND --help'`. Python, PHP and Node all say `Usage: tina4<lang> <command> [options]`; Ruby now matches. spec/cli_spec.rb and spec/cli_help_flags_spec.rb assert the new text (116 examples, 0 failures); metrics gate exit 0. 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.Ruby specifics
serve/startkeep-has--host. Only--helpis help there, soserve -h 0.0.0.0scripts don't break.-pand-dstill work.serve --port abc) prints the "Run … --help" line instead of a backtrace.migrate --create/--rollback,migrate:rollback --steps,seed --clear,init --template.testreads no arguments, so it's option-checked.ai --allcrashed on v3, becauseai.rbnever loadedTina4::VERSION. Fixed with onerequire_relative.--po) and bundled short flags (-dp), the same as Python.Usage: tina4ruby <command> [options], the same as the other three (it saidCOMMAND).testruns Tina4's inline tests, not RSpec, so there's no runner to hand arguments to as Python (pytest) and PHP (PHPUnit) do. Wrapping RSpec is a design change for its own PR.Tests
spec/cli_help_flags_spec.rb: 106 examples, running the realexe/tina4rubyin temp projects. 98 of the first 105 fail on unfixed v3, including all 66 help cases.serve -his checked three ways, including a short-lived real server on-p PORT -h 127.0.0.1that answers/health.spec/cli_spec.rb+ the help spec after the wording change: 116 examples, 0 failures.lint --helpreally runsbundle add rubocop. Running the new spec against old code can touch Gemfile.lock.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