Skip to content

Exit non-zero when arguments do not parse or a verb fails [patch] - #200

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/non-zero-exit-on-failure
Oct 9, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/non-zero-exit-on-failure

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

Main now returns int. It hands off to a new Program.Run(args) that returns:

  • 1 when the arguments do not parse (e.g. Search without -q). --help and --version still return 0.
  • 1 when the verb sets the new BaseVerb.Failed flag.
  • 0 otherwise.

Failed is set on:

  • an ValidateArgs abort (no path or query given at the prompt)
  • Scan: an invalid endpoint, Ollama being unavailable, or a non-empty failure list after describing
  • Import: a missing file or an unsupported extension
  • Search: an empty query
  • Export: an unsupported extension

"No descriptions to export" and "no images found" still exit 0, because nothing went wrong in either case. The verbs' void Run signatures are unchanged, so the menu path and existing tests are untouched.

Tests

New ProgramTests drive Program.Run for each case: missing required option → 1, Ollama unreachable (-e http://127.0.0.1:1) → 1, missing import file → 1, Stats → 0, --help → 0. I checked that the tests catch the bug: with Run changed back to always returning 0 (the old behaviour), the three non-zero tests fail. Full suite: 90 passed, 0 warnings.

Fixes #167

🤖 Generated with Claude Code

https://claude.ai/code/session_015PVg1hwPKWXb1nLDuTQgYR


Generated by Claude Code

claude added 2 commits October 7, 2026 22:25
Main returned void and every verb reported failures with Console.WriteLine,
so a script could not tell that Ollama was down, the import file was
missing, a required option was absent, or some images failed to describe.

Fixes #167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015PVg1hwPKWXb1nLDuTQgYR
Adds cases for an unsupported import or export extension, a blank search
query, an invalid Ollama endpoint, an empty prompted path and --version,
and gives every run an empty standard input so a prompt cannot block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015PVg1hwPKWXb1nLDuTQgYR
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit ba8e895 into main Oct 9, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/non-zero-exit-on-failure branch October 9, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImageDescriber exits 0 on every failure (Ollama unreachable, missing import file, missing required option, failed images)

2 participants