-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Description
The ttok command produces duplicate parameter warnings when executed via pipe input, indicating the --tokens parameter is defined multiple times in the Click CLI configuration.
Steps to Reproduce
- Install ttok via Homebrew:
brew install simonw/llm/ttok - Run ttok with piped input:
cat tmp_vault.md | ttokExpected Behavior
Command should execute cleanly without warnings and display token count.
Actual Behavior
Command displays two UserWarnings before showing results:
/Users/andy16/.local/share/uv/tools/ttok/lib/python3.12/site-packages/click/core.py:1223: UserWarning: The parameter --tokens is used more than once. Remove its duplicate as parameters should be unique.
parser = self.make_parser(ctx)
/Users/andy16/.local/share/uv/tools/ttok/lib/python3.12/site-packages/click/core.py:1216: UserWarning: The parameter --tokens is used more than once. Remove its duplicate as parameters should be unique.
self.parse_args(ctx, args)
8977573
Environment
- OS: macOS (Darwin)
- Installation Method: Homebrew (
brew install simonw/llm/ttok) - ttok Version: [run
ttok --version] - Python Version: 3.12
- Click Version: [if available]
- ttok, version 0.3
Root Cause (Suspected)
The Click CLI setup appears to have duplicate @click.option('--tokens', ...) decorators, possibly on the main command function.
Impact
- Warning pollution in terminal output
- Complicates scripting and output parsing
- Suggests potential configuration issue
Workaround
Suppress stderr: cat file.md | ttok 2>/dev/null
Additional Context
The command functions correctly (outputs accurate token count), but the warnings indicate a code quality issue. Reproduced after fresh Homebrew installation.
Previously installed via uv tool install ttok with same issue, switched to Homebrew installation - issue persists.