{"record":{"id":"d9a2eec10e1b3e81","repo":"yamadashy/repomix","slug":"invalid-token-count-threshold-value-must-be","errorCode":null,"errorMessage":"Invalid token count threshold: '${value}'. Must be a non-negative integer.","messagePattern":"Invalid token count threshold: '(.+?)'\\. Must be a non-negative integer\\.","errorType":"validation","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/cli/cliRun.ts","lineNumber":84,"sourceCode":"      )\n      .addOption(\n        new Option('--quiet', 'Suppress all console output except errors (useful for scripting)').conflicts('verbose'),\n      )\n      .addOption(\n        new Option(\n          '--stdout',\n          'Write packed output directly to stdout instead of a file (suppresses all logging)',\n        ).conflicts('output'),\n      )\n      .option('--stdin', 'Read file paths from stdin, one per line (specified files are processed directly)')\n      .option('--copy', 'Copy the generated output to system clipboard after processing')\n      .option(\n        '--token-count-tree [threshold]',\n        'Show file tree with token counts; optional threshold to show only files with ≥N tokens (e.g., --token-count-tree 100)',\n        (value: string | boolean) => {\n          if (typeof value === 'string') {\n            if (!/^\\d+$/.test(value)) {\n              throw new RepomixError(`Invalid token count threshold: '${value}'. Must be a non-negative integer.`);\n            }\n            return Number(value);\n          }\n          return value;\n        },\n      )\n      .option(\n        '--top-files-len <number>',\n        'Number of largest files to show in summary (default: 5, e.g., --top-files-len 20)',\n        (v: string) => {\n          if (!/^\\d+$/.test(v)) {\n            throw new RepomixError(`Invalid number for --top-files-len: '${v}'. Must be a non-negative integer.`);\n          }\n          return Number(v);\n        },\n      )\n      // Repomix Output Options\n      .optionsGroup('Repomix Output Options')","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/cli/cliRun.ts#L66-L102","documentation":"The `--token-count-tree` option accepts an optional numeric threshold for showing only files with ≥N tokens. Commander invokes this parser during CLI parsing, and any non-integer (or negative) string value throws immediately. Bare `--token-count-tree` (boolean) is allowed.","triggerScenarios":"Passing a non-numeric or negative value such as `--token-count-tree 1,000`, `--token-count-tree 100.5`, `--token-count-tree -1`, or a flag-swallowing typo like `--token-count-tree auto`.","commonSituations":"Users writing thousands separators or units (`1000`, `1k`) out of habit, or accidentally passing the next flag's value because `--token-count-tree` greedily consumes the following token.","solutions":["Pass a plain non-negative integer: `--token-count-tree 100`","Remove thousands separators/units (use 1000, not 1,000 or 1k)","If you want the tree without a threshold, pass the flag with no value"],"exampleFix":"// before\nrepomix --token-count-tree 1,000\n// after\nrepomix --token-count-tree 1000","handlingStrategy":"validation","validationCode":"const t = process.argv[process.argv.indexOf('--token-count-tree') + 1];\nif (typeof t === 'string' && !/^\\d+$/.test(t)) {\n  throw new Error(`--token-count-tree needs a non-negative integer, got: ${t}`);\n}","typeGuard":"const isNonNegativeInt = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isInteger(v) && v >= 0;","tryCatchPattern":"try {\n  parseArgv(argv);\n} catch (e) {\n  if (e instanceof RepomixError && e.message.includes('Invalid token count threshold')) {\n    console.error('Usage: --token-count-tree 100 (plain non-negative integer)');\n  }\n  process.exitCode = 1;\n}","preventionTips":["Always pass plain digits (no commas, decimals, units, or signs)","Remember the optional value is greedy: insert `--` or order flags to avoid swallowing the next token"],"tags":["cli","argument-validation","option-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}