Context
moon_cli.py exists so MoonDownloader can run unattended — cron, a scheduled task, a step in a larger script. That only works if the caller can tell success from failure without parsing the log.
Today the CLI does not distinguish outcomes in its exit status, so a run where 3 of 29 files failed looks identical to a clean run from the outside.
What to do
Define and implement three exit codes in moon_cli.py:
| Code |
Meaning |
0 |
every file in the batch completed |
1 |
the run completed but at least one file failed (dead link, exhausted retries, extraction failure) |
2 |
the run could not start — bad arguments, unreadable link file, invalid configuration |
Rules:
- A partial failure is still exit 1, not an exception. The remaining files must still be attempted; the code reports the outcome, it does not abort the batch.
- Exit 2 is pre-flight only. Once the first download starts, the outcome is 0 or 1.
- Keep the existing summary line on stdout unchanged — scripts may already be grepping it.
Acceptance criteria
Depends on
#28 creates docs/CLI.md. If that page does not exist yet when you open the PR, add the exit-code table to your PR and note it — the two will be reconciled on merge.
Notes for the contributor
This one touches real behaviour rather than docs or config, so read moon_cli.py end to end first. CONTRIBUTING.md has the rules that are not style preferences — in particular, moon_cli.py currently carries its own copy of the download engine, so check whether your change needs to land in moon_engine.py too.
Comment here before you start.
Context
moon_cli.pyexists so MoonDownloader can run unattended — cron, a scheduled task, a step in a larger script. That only works if the caller can tell success from failure without parsing the log.Today the CLI does not distinguish outcomes in its exit status, so a run where 3 of 29 files failed looks identical to a clean run from the outside.
What to do
Define and implement three exit codes in
moon_cli.py:012Rules:
Acceptance criteria
tests/covers all three, with the network stubbed the waytest_no_chrome.pyalready doesdocs/CLI.mdDepends on
#28 creates
docs/CLI.md. If that page does not exist yet when you open the PR, add the exit-code table to your PR and note it — the two will be reconciled on merge.Notes for the contributor
This one touches real behaviour rather than docs or config, so read
moon_cli.pyend to end first.CONTRIBUTING.mdhas the rules that are not style preferences — in particular,moon_cli.pycurrently carries its own copy of the download engine, so check whether your change needs to land inmoon_engine.pytoo.Comment here before you start.