Context
split_book.py, main() / build_arg_parser(). Compare to --fixed/--target-pages, which are already validated as positive integers with a clear error message.
Problem
--level has no validation. Internally, _walk_outline starts depth counting at 1, so --level 0 or any negative value can never match any outline entry — it silently falls through to the generic "no usable outline found at --level N" error, even on a PDF that has a perfectly good outline.
Reproduction
- Use any PDF with a normal, working outline at level 1.
python split_book.py book.pdf --level 0 --list
- Output:
Error: no usable outline found at --level 0. Try a different --level (e.g. --level 1), ... — despite the outline existing and being perfectly usable at level 1. Confirmed.
Expected
--level should be validated as a positive integer up front (same pattern already used for --fixed/--target-pages in main()), with a message like: Error: --level must be a positive integer, got 0.
Actual
No validation; produces a confusing generic "no outline found" message instead.
Acceptance criteria
Context
split_book.py,main()/build_arg_parser(). Compare to--fixed/--target-pages, which are already validated as positive integers with a clear error message.Problem
--levelhas no validation. Internally,_walk_outlinestarts depth counting at 1, so--level 0or any negative value can never match any outline entry — it silently falls through to the generic "no usable outline found at --level N" error, even on a PDF that has a perfectly good outline.Reproduction
python split_book.py book.pdf --level 0 --listError: no usable outline found at --level 0. Try a different --level (e.g. --level 1), ...— despite the outline existing and being perfectly usable at level 1. Confirmed.Expected
--levelshould be validated as a positive integer up front (same pattern already used for--fixed/--target-pagesinmain()), with a message like:Error: --level must be a positive integer, got 0.Actual
No validation; produces a confusing generic "no outline found" message instead.
Acceptance criteria
--level 0and negative--levelvalues are rejected with a clear, specific error before any outline parsing is attempted.--fixed/--target-pagesvalidation tests.