发布

  • refactor(core): move CLIOptions to core api.cli package (#475)

    frostbyte_neo 发布于 2026-04-30 08:13:53 +00:00

    • refactor(core): move CLIOptions to core api.cli package

    Objective: Downstream tools (opendataloader-pdfua) need CLI option
    parsing logic to populate Config from a CommandLine. They had to
    depend on opendataloader-pdf-cli, which is not published to Maven
    Central — forcing a local mvn install step before any build.

    Approach: Move CLIOptions to core under org.opendataloader.pdf.api.cli
    so downstream tools depend only on core (which is already on Central).
    The cli module keeps CLIMain as the executable entry point and adds
    an import to the new package. Stable members for downstream use are
    documented on the class: defineOptions, addAllTo, applyAllTo, FOLDER_OPTION.

    Evidence:

    • mvn test in core: 634/634 pass (incl. moved CLIOptionsTest,
      CLIOptionsContentSafetyTest)
    • mvn test in cli: 5/5 pass
    • npm test (vitest, node wrapper): 32/32 pass
    • pytest (python wrapper, cli_options + convert_integration): 13/13 pass
    • --export-options byte-level diff vs existing options.json: identical
    • shaded jar manifest: Main-Class still org.opendataloader.pdf.cli.CLIMain

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    • review: tighten CLIOptions stability contract + cover addAllTo edge cases

    Objective: Code review on #475 flagged that the class-level Javadoc
    declared four "stable" members but did nothing to discourage downstream
    from depending on the dozens of other public statics (option-name
    constants, createConfigFromCommandLine, exportOptionsAsJson). Also
    asked for direct test coverage of the addAllTo external-Options pattern
    that pdfua relies on.

    Approach:

    • Rewrite the class Javadoc to explicitly mark all non-listed public
      members as internal — public visibility for cross-package access
      only, may change in any release. Add a usage example so the
      intended pattern (custom Options + addAllTo + applyAllTo) is visible
      at the top of the file.
    • Add two tests covering the contract pdfua actually depends on:
      addAllTo preserves pre-existing downstream options, and addAllTo
      is idempotent (commons-cli's silent-replace-by-long-name behavior
      is pinned so a future commons-cli upgrade that changes it surfaces
      here).

    Evidence:

    • mvn test CLIOptionsTest: 61/61 pass (incl. 2 new)
    • mvn install: BUILD SUCCESS
    • mvn javadoc:jar -P release: BUILD SUCCESS (doclint passes new Javadoc)
    • Probe of commons-cli 1.11 confirms Options.addOption silently replaces
      by long-name (count stays 1, last description wins) — test pins this.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com

    下载附件