CLI: -j/--json produces no output, and --output-dir is ignored in JSON mode
Running the CLI with -j / --json produces no output at all, and --output-dir is ignored in that mode.
Repro
$ pyonenote -j -f Section.one -o out/
$ echo "exit=$? stdout=(empty) out/=(empty)"
exit=0 stdout=(empty) out/=(empty)
The file is parsed successfully — the JSON is built and then discarded.
1. -j prints nothing
process_onenote_file() builds the JSON and returns it:
https://github.com/DissectMalware/pyOneNote/blob/main/pyOneNote/Main.py#L75
return json.dumps(data)
but the only caller never captures or prints the return value:
https://github.com/DissectMalware/pyOneNote/blob/main/pyOneNote/Main.py#L100
process_onenote_file(file, args.output_dir, args.extension, args.json)
So with -j, the human-readable dump is correctly suppressed, the JSON is correctly generated — and then nothing is emitted.
I realize the return value is the contract for library consumers (process_onenote_file() is imported and used that way), and that part works fine. This is purely about the CLI surface: the flag is advertised as "Generate JSON output only, no dumps or prints", but as a CLI flag it currently has no observable effect.
2. --output-dir is not honored under -j
The only use of output_dir is the embedded-file extraction loop, which sits inside if not json_output::
https://github.com/DissectMalware/pyOneNote/blob/main/pyOneNote/Main.py#L30
So in JSON mode nothing is written to --output-dir — not the extracted files, and not the JSON either. Passing -o alongside -j silently does nothing.
Possible directions
Either would resolve (1); (2) depends on which you consider correct:
- Emit on stdout —
if args.json: print(result). Keeps-jpipeable (| jq), and leaves--output-dirlegitimately unused in JSON mode (consistent with "no dumps"). Smallest change. - Write to
--output-dir— e.g.<output_dir>/<section>.json, which would make-obehave consistently across modes. Note-odefaults to"./", so distinguishing "user passed-o" from the default would need a sentinel default.
Happy to send a PR for whichever you prefer — or feel free to close if the CLI -j behavior is intentional and the library return value is the only supported path.