使用cargo-thanku快速生成Rust项目依赖致谢

程序员咋不秃头 2025-04-13 00:16:15

Cargo Thanku

Github:https://github.com/YuniqueUnic/cargo-thanku

一个用于生成 Rust 项目依赖致谢的命令行工具。

觉得还不错的话, 请帮我 Star 一下捏~

主要特性支持多种输出格式(Markdown 表格/列表、JSON、TOML、YAML、CSV)自动从 crates.io 和 GitHub 获取依赖信息支持可配置的并发处理实现请求失败重试机制提供命令行自动补全(支持 Bash、Zsh、Fish、PowerShell 和 Elvish)支持多语言(中文/英文/日文/韩文/西班牙文/法文/德文/意大利文)安装

确保系统已安装 Rust 工具链,然后执行:

# 安装 cargo-thankucargo install cargo-thanku# 生成 shell 补全脚本(可选)cargo thanku completions bash > ~/.local/share/bash-completion/completions/cargo-thanku使用方法

基本用法

# 为你的项目生成致谢文档cargo thanku# 指定输出格式cargo thanku -f markdown-table # 可选:markdown-list, json, toml, yaml# 设置 GitHub 令牌以获取更多信息并自动点赞cargo thanku -t YOUR_GITHUB_TOKEN# 切换语言cargo thanku -l zh # 支持 zh/en/ja/ko/es/fr/de/it

高级选项

# 配置并发请求数cargo thanku -j 10 # 设置最大并发请求数为 10# 调整重试次数cargo thanku -r 5 # 设置最大重试次数为 5# 自定义输出文件cargo thanku -o custom_thanks.md# 启用详细日志cargo thanku -v# 过滤掉相对路径导入的 libscargo thanku --no-relative-libs

格式转换

在不同的输出格式之间进行转换:

# 不支持 cargo thanku convert 模式语法调用# 将单个文件转换为多种格式cargo-thanku convert input.md -o markdown-table,json,yaml# 简短的命令别名# Short command aliasescargo-thanku cvt input.csv -o markdown-table,yamlcargo-thanku conv input.md -o jsoncargo-thanku convt input.yaml -o markdown-list

转换器将:

在与输入文件相同的目录下创建一个 converted 目录生成带有适当扩展名的输出文件支持所有受支持格式之间的转换 (markdown-table, markdown-list, json, toml, yaml, csv)

命令行参数

参数

描述

默认值

-i, --input

输入 Cargo.toml 文件路径

-

-o, --outputs

输出文件格式

-

-l, --language

语言 (zh/en/ja/ko/es/fr/de/it)

zh

-v, --verbose

启用详细日志记录

false

命令行补全

为不同的 shell 生成命令行补全脚本:

# Bashcargo thanku completions bash > ~/.local/share/bash-completion/completions/cargo-thanku# Zshcargo thanku completions zsh > ~/.zsh/_cargo-thanku# Fishcargo thanku completions fish > ~/.config/fish/completions/cargo-thanku.fish# PowerShellmkdir -p $PROFILE\..\Completionscargo thanku completions powershell > $PROFILE\..\Completions\cargo-thanku.ps1# Elvishcargo thanku completions elvish > ~/.elvish/lib/cargo-thanku.elv命令行参数

参数

描述

默认值

-i, --input

输入的 Cargo.toml 文件路径

Cargo.toml

-o, --output

输出文件路径

thanks.md

-f, --format

输出格式

markdown-table

-t, --token

GitHub API 令牌

-

-l, --language

语言 (zh/en/ja/ko/es/fr/de/it)

zh

-v, --verbose

启用详细日志

false

-j, --concurrent

最大并发请求数

5

-r, --retries

最大重试次数

3

--no-relative-libs

过滤掉相对路径导入的库

false

输出格式

Markdown 表格

| 名称 | 描述 | 来源 | 统计 | 状态 ||------|------|------|------|------|| [serde](https://crates.io/crates/serde) | 序列化框架 | [GitHub](https://github.com/serde-rs/serde) | 3.5k | ✅ |

Markdown 列表

# 依赖项- [serde](https://crates.io/crates/serde) [序列化框架](https://github.com/serde-rs/serde) ( 3.5k) ✅

MARKDOWN/JSON/CSV/YAML

同时支持结构化输出格式,方便程序化使用。

重要说明设置 GitHub 令牌(通过 -t 或环境变量 GITHUB_TOKEN)可以:获取更多仓库信息自动获取依赖仓库 stars提高 API 访问限制依赖处理失败时:不会中断整体处理过程在输出中会标记为 ❌显示错误信息以便调试语言代码支持:支持灵活的格式(如 "zh"、"zh_CN"、"zh_CN.UTF-8")自动提取主要语言代码对于拼写错误会提供相似代码建议致谢

本项目本身也使用了许多优秀的 Rust crate。以下是一些主要依赖:

[!TIP] 由 cargo-thanku 工具生成

名称

描述

Crates.io

来源

统计

状态

Normal

anyhow

Flexible concrete Error type built on std::error::Error

anyhow

GitHub

cargo_metadata

structured access to the output of cargo metadata

cargo_metadata

GitHub

clap

A simple to use, efficient, and full-featured Command Line Argument Parser

clap

GitHub

clap_complete

Generate shell completion scripts for your clap::Command

clap_complete

GitHub

futures

An implementation of futures and streams featuring zero allocations, composability, and iterator-like interfaces.

futures

GitHub

reqwest

higher level HTTP client library

reqwest

GitHub

rust-i18n

Rust I18n is use Rust codegen for load YAML file storage translations on compile time, and give you a t! macro for simply get translation texts.

rust-i18n

GitHub

serde

A generic serialization/deserialization framework

serde

GitHub

serde_json

A JSON serialization file format

serde_json

GitHub

serde_yaml

YAML data format for Serde

serde_yaml

GitHub

strsim

Implementations of string similarity metrics. Includes Hamming, Levenshtein, OSA, Damerau-Levenshtein, Jaro, Jaro-Winkler, and Sørensen-Dice.

strsim

GitHub

thiserror

derive(Error)

thiserror

GitHub

tokio

An event-driven, non-blocking I/O platform for writing asynchronous I/O backed applications.

tokio

GitHub

toml

A native Rust encoder and decoder of TOML-formatted files and streams. Provides implementations of the standard Serialize/Deserialize traits for TOML data to facilitate deserializing and serializing Rust structures.

toml

GitHub

tracing

Application-level tracing for Rust.

tracing

GitHub

tracing-subscriber

Utilities for implementing and composing tracing subscribers.

tracing-subscriber

GitHub

url

URL library for Rust, based on the WHATWG URL Standard

url

GitHub

Development

assert_fs

Filesystem fixtures and assertions for testing.

assert_fs

GitHub

pretty_assertions

Overwrite assert_eq! and assert_ne! with drop-in replacements, adding colorful diffs.

pretty_assertions

GitHub

tokio-test

Testing utilities for Tokio- and futures-based code

tokio-test

GitHub

要查看完整的依赖列表和致谢,请运行:

cargo thanku许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

0 阅读:0
程序员咋不秃头

程序员咋不秃头

感谢大家的关注