Skip to content

docs: fix three stale CLI flags in the how-to examples (--line-number, --tokens, --exclude-from-tree) - #335

Merged
ODAncona merged 3 commits into
mufeedvh:mainfrom
cnYui:docs/fix-stale-cli-flags-in-how-to-examples
Sep 5, 2026
Merged

docs: fix three stale CLI flags in the how-to examples (--line-number, --tokens, --exclude-from-tree)#335
ODAncona merged 3 commits into
mufeedvh:mainfrom
cnYui:docs/fix-stale-cli-flags-in-how-to-examples

Conversation

@cnYui

@cnYui cnYui commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Three flags used in the "how to" examples no longer exist in the CLI, so every one of those commands fails outright — clap rejects unknown arguments:

Documented Reality (crates/code2prompt/src/args.rs)
--line-number pub line_numbers: bool-l / --line-numbers
--tokens removed; the token count is always printed, --token-format <raw,format> selects the rendering
--exclude-from-tree removed; pruning is the default, --full-directory-tree is the opt-out

Reproduced against main (6f7a7ff), after cargo build -p code2prompt:

$ ./target/debug/code2prompt . --line-number
error: unexpected argument '--line-number' found
  tip: a similar argument exists: '--line-numbers'
exit=2

$ ./target/debug/code2prompt . --tokens
error: unexpected argument '--tokens' found
  tip: a similar argument exists: '--token-map'
exit=2

$ ./target/debug/code2prompt . --exclude-from-tree
error: unexpected argument '--exclude-from-tree' found
  tip: a similar argument exists: '--exclude'
exit=2

There is no clap alias or infer_long_args keeping the old spellings alive (grep -rnE 'clap\(.*alias|visible_alias|infer_long_args' crates/ → no output), and --exclude-from-tree appears nowhere in crates/ any more.

--help confirms the real names:

$ ./target/debug/code2prompt --help | grep -E 'line-numbers|full-directory-tree|token-format|encoding'
      --full-directory-tree
      --encoding <cl100k, p50k, p50k_edit, r50k>
      --token-format <raw,format>
  -l, --line-numbers

Change

Three independent commits, one per flag, so a smaller subset can be taken if preferred:

  1. --line-number--line-numbers (pure rename).

  2. --tokens--token-format=format; the tokenizer example only needs --encoding=p50k, so the dead flag is just dropped there. The count itself is printed unconditionally now (crates/code2prompt/src/main.rs, format_number(token_count, &session.config.token_format)).

  3. --exclude-from-tree removed from the exclude example. The surrounding sentence ("Exclude files/folders from the source tree based on exclude patterns") stays accurate, because that pruning is now the default:

    // crates/code2prompt-core/src/path.rs
    let include_in_tree = config.full_directory_tree || entry_match;

    Only the English page gains one extra line pointing at --full-directory-tree as the opt-out — I deliberately did not machine-translate that sentence into the six localized copies, so their diff stays a pure token deletion.

14 files: README_ES.md, website/src/content/docs/docs/how_to/cli.mdx, and the de/es/fr/ja/ru/zh copies of cli.mdx and filter_files.md. README.md and the English filter_files.md are untouched (the former does not contain these flags, the latter does not exist).

Verification

Tree semantics, on a scratch dir containing keep.txt, drop.wav, sub/also.wav:

$ code2prompt DIR --exclude="*.wav" -q -O -
treedemo1
├── keep.txt
└── sub

$ code2prompt DIR --exclude="*.wav" --full-directory-tree -q -O -
treedemo1
├── drop.wav
├── keep.txt
└── sub
    └── also.wav

Every command as it now reads in the docs exits 0:

--exclude=*.npy,*.wav -> exit=0
--token-format=format -> exit=0
--encoding=p50k       -> exit=0
--line-numbers        -> exit=0

Post-change greps are empty:

$ grep -rn --exclude-dir=.git -- '--exclude-from-tree' .   # 0
$ grep -rnE --exclude-dir=.git -- '--line-number([^s]|$)' .  # 0
$ grep -rn --exclude-dir=.git -- '--tokens' .              # 0

The docs site still builds, and the rendered page picks up the new note:

$ cd website && pnpm install --frozen-lockfile && pnpm build
[build] 174 page(s) built in 17.27s
[build] Complete!
$ grep -c 'full-directory-tree' dist/docs/how_to/cli/index.html   # 1
$ grep -rn --binary-files=text -- '--exclude-from-tree' dist/     # 0

Limitations

🤖 Generated with Claude Code

cnYui and others added 3 commits September 5, 2026 23:46
clap derives the long name from the field, so `line_numbers` in
crates/code2prompt/src/args.rs is exposed as `-l` / `--line-numbers`.
The documented `--line-number` is rejected with
"error: unexpected argument '--line-number' found".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`--tokens` no longer exists; the CLI now always prints the token count
and `--token-format <raw,format>` selects how it is rendered
(crates/code2prompt/src/args.rs, crates/code2prompt/src/main.rs).
The tokenizer example only needs `--encoding`, so the dead flag is
simply dropped there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
That flag no longer exists. Pruning non-matching entries from the source
tree is now the default: crates/code2prompt-core/src/path.rs computes
`let include_in_tree = config.full_directory_tree || entry_match;`, so
`--full-directory-tree` is the opt-out. The surrounding sentence stays
accurate, only the dead flag is removed; the English page gains one line
pointing at `--full-directory-tree`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ODAncona
ODAncona merged commit 12d19cc into mufeedvh:main Sep 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants