code-stats
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Statistics
代码统计
Quickly analyze codebase size, composition, and changes.
快速分析代码库的规模、构成及变更情况。
tokei - Line Counts
tokei - 代码行数统计
bash
undefinedbash
undefinedCount all code
统计所有代码
tokei
tokei
Compact output sorted by code
按代码量排序的精简输出
tokei --compact --sort code
tokei --compact --sort code
Specific languages
指定编程语言
tokei --type=TypeScript,JavaScript
tokei --type=TypeScript,JavaScript
Exclude directories
排除目录
tokei --exclude node_modules --exclude dist
tokei --exclude node_modules --exclude dist
JSON output for scripting
生成JSON输出用于脚本处理
tokei --output json | jq '.Total.code'
undefinedtokei --output json | jq '.Total.code'
undefinedSample Output
示例输出
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
TypeScript 45 12847 9823 1456 1568
JavaScript 12 2341 1876 234 231
-------------------------------------------------------------------------------
Total 57 15188 11699 1690 1799
==============================================================================================================================================================
Language Files Lines Code Comments Blanks
===============================================================================
TypeScript 45 12847 9823 1456 1568
JavaScript 12 2341 1876 234 231
-------------------------------------------------------------------------------
Total 57 15188 11699 1690 1799
===============================================================================difft - Semantic Diffs
difft - 语义化差异对比
bash
undefinedbash
undefinedCompare files
对比文件
difft old.ts new.ts
difft old.ts new.ts
Inline mode
行内模式
difft --display=inline old.ts new.ts
difft --display=inline old.ts new.ts
With git
与Git结合使用
GIT_EXTERNAL_DIFF=difft git diff
GIT_EXTERNAL_DIFF=difft git show HEAD~1
undefinedGIT_EXTERNAL_DIFF=difft git diff
GIT_EXTERNAL_DIFF=difft git show HEAD~1
undefinedWhy Semantic?
为什么选择语义化对比?
| Traditional diff | difft |
|---|---|
| Line-by-line | AST-aware |
| Shows moved as delete+add | Recognizes moves |
| Whitespace sensitive | Ignores formatting |
| 传统差异对比 | difft |
|---|---|
| 逐行对比 | 基于AST识别 |
| 将移动代码显示为删除+添加 | 可识别代码移动 |
| 对空白字符敏感 | 忽略格式变化 |
Quick Reference
快速参考
| Task | Command |
|---|---|
| Count all code | |
| Compact output | |
| Sort by code | |
| TypeScript only | |
| JSON output | |
| Exclude dir | |
| Semantic diff | |
| Git diff | |
| 任务 | 命令 |
|---|---|
| 统计所有代码 | |
| 精简输出 | |
| 按代码量排序 | |
| 仅统计TypeScript | |
| 生成JSON输出 | |
| 排除目录 | |
| 语义化差异对比 | |
| Git差异对比 | |
When to Use
使用场景
- Getting quick codebase overview
- Comparing code changes semantically
- Understanding project composition
- Reviewing refactoring impact
- Tracking codebase growth
- 快速了解代码库概况
- 语义化对比代码变更
- 分析项目构成
- 评估重构影响
- 跟踪代码库增长情况
Additional Resources
额外资源
For detailed patterns, load:
- - Filtering, output formats, CI integration
./references/tokei-advanced.md - - Display modes, git integration, language support
./references/difft-advanced.md
如需详细用法,请查看:
- - 过滤规则、输出格式、CI集成
./references/tokei-advanced.md - - 显示模式、Git集成、语言支持
./references/difft-advanced.md