feat(cli): accept both bare flags and legacy yes/no for --if-add-* args

Resolves PR #272 review #10/P5. The --if-add-node-id / -node-summary /
-doc-description / -node-text args were store_true, which rejected the
documented yes/no values and left default-on options impossible to disable
from the CLI. They now use nargs='?' + const=True + a yes/no-coercing type:

  --if-add-node-id        -> on
  --if-add-node-id no     -> off   (legacy form still works)
  (omitted)               -> use the IndexConfig default

README updated to the flag usage (noting the legacy `no` off-switch), and
--if-add-node-text is now documented too.

Decisions from the review:
- #7 (api_key semantics): verified FALSE POSITIVE — 0.2.x is a cloud SDK whose
  api_key is a PageIndex cloud key (cloud_api.LegacyCloudAPI + docs.pageindex.ai/sdk),
  matching the new SDK. No change.
- #11 (if_add_doc_description default True): kept intentionally (open mode).

Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
This commit is contained in:
mountain 2026-07-08 19:11:52 +08:00
parent cf7f5ce9bf
commit 89132cb94c
3 changed files with 36 additions and 11 deletions

View file

@ -238,10 +238,13 @@ You can customize the processing with additional optional arguments:
--toc-check-pages Pages to check for table of contents (default: 20)
--max-pages-per-node Max pages per node (default: 10)
--max-tokens-per-node Max tokens per node (default: 20000)
--if-add-node-id Add node ID (yes/no, default: yes)
--if-add-node-summary Add node summary (yes/no, default: yes)
--if-add-doc-description Add doc description (yes/no, default: yes)
--if-add-node-id Add node IDs (on by default; disable with: --if-add-node-id no)
--if-add-node-summary Add node summaries (on by default; disable with: --if-add-node-summary no)
--if-add-doc-description Add a document description (on by default; disable with: --if-add-doc-description no)
--if-add-node-text Add raw text to nodes (off by default; enable with: --if-add-node-text)
```
These flags take no value by default (a bare `--if-add-node-id` turns it on); the
legacy `--if-add-node-id no` form still works for turning an option off.
</details>
<details>