classname-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Class Name Search Guide

类名搜索指南

Windows CLI Setup

Windows CLI 配置

  1. Run
    echo --%
  2. If output is empty (PowerShell): Add
    --%
    before arguments (e.g.,
    --% '^flex$'
    )
  3. If not PowerShell: Run
    npx -y node -e "console.log(process.argv[1])" "^test"
    . If output is
    test
    instead of
    ^test
    , escape
    ^
    as
    ^^
    (e.g.,
    ^flex$
    ^^flex$
    )
See CLI Reference for details.
  1. 运行
    echo --%
  2. 如果输出为空(PowerShell环境):在参数前添加
    --%
    (例如:
    --% '^flex$'
  3. 如果不是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 the
--verbose
option if you want to include files with 0 matches in the output.
[!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"}
<!-- prettier-ignore-end -->
[!IMPORTANT]
matched
is the regex match;
className
is the full class name containing that match.
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.
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"}
<!-- prettier-ignore-end -->
[!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