CLI Exit Codes

NextDither-cli.exe reports what happened with its exit code, so a build script can react without reading its output.

Code Meaning
0 Every image converted. Warnings do not change this.
1 One or more images failed.
2 The command itself was wrong: an unknown flag, a preset that could not be read, an input that does not exist, a setting outside its allowed range. Nothing was converted.
3 Refused: outputs already exist and no overwrite decision was given. Nothing was written.

Code 3 is separate from 1 on purpose. Nothing is broken - NextDither simply will not choose between replacing your files and ignoring them. Pass --overwrite force or --overwrite skip to say which you meant.

Warnings never change the exit code. A clamped colour count or a colour key that matched nothing is worth reading, but a build that stopped on one would stop on almost every real conversion.

In a batch file

NextDither-cli.exe convert art\ --out gfx\ --preset "My Game" --overwrite force
if errorlevel 1 (
    echo Graphics conversion failed.
    exit /b 1
)

if errorlevel 1 is true for any code of 1 or more, which is what you want here: both a real failure and a refusal should stop the build.

In PowerShell

NextDither-cli.exe convert art\ --out gfx\ --preset "My Game" --overwrite force
if ($LASTEXITCODE -ne 0) {
    throw "Graphics conversion failed with code $LASTEXITCODE"
}

Checking before converting

A plain re-run is not a cheap way to check whether a folder is already converted: NextDither converts every image before it discovers a name collision, at the point it tries to write the file, so re-running the CLI over an already-converted folder does the full conversion work and then throws it away as refused.

--dry-run is the cheap check. It exits with the code the real run would produce, from file names and existing files alone, without converting a single image:

NextDither-cli.exe convert art\ --out gfx\ --dry-run
if ($LASTEXITCODE -eq 3) {
    Write-Host "Outputs already exist. Re-run with --overwrite force to replace them."
}

Interrupting a run

Pressing Ctrl-C stops the program. No half-written file is ever left behind: every output is written to a temporary file first and renamed into place only once it is complete.