返回 Skill 列表
extension
分类: 开发与工程无需 API Key

rust-clap

Rust Clap CLI参数解析的最佳实践。在使用clap编写、审查或重构Rust CLI应用程序时应运用此技能。触发于涉及参数解析、CLI设计、子命令以及Rust中的命令行界面的任务。

person作者: jakexiaohubgithub

Rust Clap Best Practices

Comprehensive best practices guide for building CLI applications in Rust using clap. Contains 42 rules across 8 categories, prioritized by impact to guide CLI design, argument parsing, and testing.

When to Apply

Reference these guidelines when:

  • Designing new Rust CLI applications
  • Adding arguments or subcommands to existing CLIs
  • Validating and parsing command-line input
  • Writing integration tests for CLI tools
  • Improving help text and user experience

Rule Categories by Priority

| Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Type-Driven Design | CRITICAL | type- | | 2 | Derive API Patterns | CRITICAL | derive- | | 3 | Argument Configuration | HIGH | arg- | | 4 | Validation & Parsing | HIGH | valid- | | 5 | Subcommand Architecture | MEDIUM-HIGH | subcmd- | | 6 | Help & Documentation | MEDIUM | help- | | 7 | Error Handling | MEDIUM | error- | | 8 | Testing Patterns | LOW-MEDIUM | test- |

Quick Reference

1. Type-Driven Design (CRITICAL)

2. Derive API Patterns (CRITICAL)

3. Argument Configuration (HIGH)

4. Validation & Parsing (HIGH)

5. Subcommand Architecture (MEDIUM-HIGH)

6. Help & Documentation (MEDIUM)

7. Error Handling (MEDIUM)

8. Testing Patterns (LOW-MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

| File | Description | |------|-------------| | references/_sections.md | Category definitions and ordering | | assets/templates/_template.md | Template for new rules | | metadata.json | Version and reference information |