Skip to content

BUG: ttok command produces duplicate parameter warnings #23

@pascalandy

Description

@pascalandy

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

  1. Install ttok via Homebrew: brew install simonw/llm/ttok
  2. Run ttok with piped input:
   cat tmp_vault.md | ttok

Expected 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions