Skip to content

Fix exit code of an unknown command and the model doc comment - #13

Merged
necessarylion merged 1 commit into
mainfrom
fix/unknown-command-exit-code
Nov 3, 2026
Merged

necessarylion merged 1 commit into
mainfrom
fix/unknown-command-exit-code

Conversation

@mydoxie

@mydoxie mydoxie commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem 1: unknown command exits with 0

In an app with package commands (like an app with dox_queue), dox nope:cmd prints "Could not find a command" but exits with 0. So scripts and CI think the command worked.

The cause: the runner file .dart_tool/dox/commands.dart returned with exit code 0 when no package had the command.

Fix: the runner now sets exit code 1. The message stays on stdout, the same as the other error messages of the CLI. The runner file was only written again when the packages changed. Now it is also written again when its text is not the same as the new one, so old apps get the fix too.

Problem 2: analyzer info in the new model

dox make:model wrote a doc comment with <String>['title', 'body']. The analyzer shows the info unintended_html_in_doc_comment for it.

Fix: the code is now in backticks. No other make:* stub had this problem.

Tests

  • The e2e test checks that an unknown command exits with 1.
  • A new test checks that an old runner file is written again.
  • A new test runs every make:* generator and checks that no doc comment has <...> outside backticks.
  • dart analyze --fatal-infos, dart format and dart test (142 tests) pass.

An unknown command in an app with package commands exited with 0.
The runner now sets exit code 1. An old runner file is written again
when its text is not the same as the new one.

The make:model stub had <String>[...] in a doc comment, which gave
the analyzer info unintended_html_in_doc_comment. It is now in
backticks.
@mydoxie

mydoxie commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Bot review

Verdict: no blocking problems. dart test passes locally (142 tests).

What I checked:

  • Unknown command: the runner now sets exitCode = 1 and returns. The Dart VM exits with that code, and bin/dox.dart passes it on. A command that throws still exits 1 (or its own code). Two commands with the same name still exit(1). --dox-list still exits 0.
  • Runner rewrite: it runs only on the cached path, and only when the text differs. runnerSource only depends on the cached libraries map (the JSON keeps key order) and on constants. So the text is the same on every run, and it does not rebuild every time. There is no loop. The cost is one small file read per run.
  • Two dox at the same time: _writeAtomic writes a temp file named with the pid, then renames it. Both processes write the same text, and a reader never sees a half-written file. That is safe.
  • Tests: each new check fails without its fix. The e2e test checks the exit code. The unit test checks that the old runner text is written again. The stub test finds the <String>[...] text in the model doc comment.
  • CHANGELOG: both lines are under Unreleased. No version bump.

Nits (not blocking):

  • Between runner.existsSync() and runner.readAsStringSync(), another dox could delete the runner (when its discovery finds no packages). Then this run would crash. This is very rare. A try/catch that writes the runner again would cover it.
  • The stub test flags any < in a doc comment, also a plain a < b. That is fine for now. Change the rule if a stub ever needs it.

@necessarylion
necessarylion merged commit 255abe8 into main Nov 3, 2026
1 check passed
@necessarylion
necessarylion deleted the fix/unknown-command-exit-code branch November 3, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants