classname-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClass Name Search Guide
类名搜索指南
Windows CLI Setup
Windows CLI 配置
- Run
echo --% - If output is empty (PowerShell): Add before arguments (e.g.,
--%)--% '^flex$' - If not PowerShell: Run . If output is
npx -y node -e "console.log(process.argv[1])" "^test"instead oftest, escape^testas^(e.g.,^^→^flex$)^^flex$
See CLI Reference for details.
- 运行
echo --% - 如果输出为空(PowerShell环境):在参数前添加(例如:
--%)--% '^flex$' - 如果不是PowerShell环境:运行。如果输出为
npx -y node -e "console.log(process.argv[1])" "^test"而非test,则将^test转义为^(例如:^^→^flex$)^^flex$
详情请查看CLI 参考。
Count matched class names per file
按文件统计匹配的类名数量
[!WARNING]
AI manual counting is unreliable. Always use this command to count class names.
Command:
bash
npx classname-search stats 'src/**/*.jsx' 'text-'Output:
text
src/components/Header.jsx: 3 matches
src/components/Main.jsx: 4 matches
Total: 7 matches in 2 files[!NOTE]
By default, only files containing matched class names are listed.
Use theoption if you want to include files with 0 matches in the output.--verbose
[!WARNING]
AI手动计数不可靠。请始终使用此命令统计类名数量。
命令:
bash
npx classname-search stats 'src/**/*.jsx' 'text-'输出:
text
src/components/Header.jsx: 3 matches
src/components/Main.jsx: 4 matches
Total: 7 matches in 2 files[!NOTE]
默认情况下,仅列出包含匹配类名的文件。
如果希望在输出中包含匹配数为0的文件,请使用选项。--verbose
Search for class names
搜索类名
Command:
bash
npx classname-search search 'src/components/**/*.jsx' 'flex'Output (search):
<!-- prettier-ignore-start -->
jsonl
{"file":"src/components/Header.jsx","line":3,"matched":"flex","className":"flex","classValue":"flex flex-col"}
{"file":"src/components/Header.jsx","line":3,"matched":"flex","className":"flex-col","classValue":"flex flex-col"}
{"file":"src/components/Header.jsx","line":4,"matched":"flex","className":"inline-flex","classValue":"inline-flex"}[!IMPORTANT]
is the regex match;matchedis the full class name containing that match.className
File output:
Redirect output to a file for large results or when requested by the user.
Working from file output is strongly recommended to avoid truncation and hallucination.
Working from file output is strongly recommended to avoid truncation and hallucination.
bash
npx classname-search search 'src/components/**/*.jsx' 'flex' > 'filename.jsonl'命令:
bash
npx classname-search search 'src/components/**/*.jsx' 'flex'搜索输出:
<!-- prettier-ignore-start -->
jsonl
{"file":"src/components/Header.jsx","line":3,"matched":"flex","className":"flex","classValue":"flex flex-col"}
{"file":"src/components/Header.jsx","line":3,"matched":"flex","className":"flex-col","classValue":"flex flex-col"}
{"file":"src/components/Header.jsx","line":4,"matched":"flex","className":"inline-flex","classValue":"inline-flex"}[!IMPORTANT]
是正则匹配结果;matched是包含该匹配项的完整类名。className
文件输出:
将输出重定向到文件,以处理大量结果或满足用户需求。强烈建议从文件输出中进行操作,以避免截断和错误。
bash
npx classname-search search 'src/components/**/*.jsx' 'flex' > 'filename.jsonl'Search and replace class names
搜索并替换类名
Command:
bash
npx classname-search replace 'src/components/**/*.jsx' -- '-slate-(\d+)$' '-neutral-$1'Output:
text
Replaced 8 matches of "-slate-(\d+)$" with "-neutral-$1" in 3 files.命令:
bash
npx classname-search replace 'src/components/**/*.jsx' -- '-slate-(\d+)$' '-neutral-$1'输出:
text
Replaced 8 matches of "-slate-(\d+)$" with "-neutral-$1" in 3 files.Remove class names
删除类名
Command:
bash
npx classname-search remove 'src/components/**/*.jsx' '^font-normal$'Output:
text
Removed 5 matches of "^font-normal$" with "" in 2 files.命令:
bash
npx classname-search remove 'src/components/**/*.jsx' '^font-normal$'输出:
text
Removed 5 matches of "^font-normal$" with "" in 2 files.CLI Reference
CLI 参考
Fetch
https://raw.githubusercontent.com/yuichiroharai/classname-search/main/README.md获取
https://raw.githubusercontent.com/yuichiroharai/classname-search/main/README.md