cli-developer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCLI Developer
CLI 开发者
Purpose
用途
Provides expertise in building robust, user-friendly command-line applications and terminal interfaces. Covers argument parsing, interactive prompts, TUI frameworks, and shell automation across multiple languages.
提供构建健壮、易用的命令行应用和终端界面的专业能力。涵盖多语言下的参数解析、交互式提示、TUI框架以及Shell自动化相关内容。
When to Use
适用场景
- Building CLI applications in any language
- Creating interactive terminal user interfaces
- Implementing command-line argument parsing
- Building shell scripts and automation tools
- Adding progress bars, spinners, and colors
- Creating REPL-style applications
- Distributing CLI tools as packages
- 用任意语言构建CLI应用
- 创建交互式终端用户界面
- 实现命令行参数解析
- 构建Shell脚本与自动化工具
- 添加进度条、加载动画与彩色输出
- 创建REPL风格的应用
- 将CLI工具打包分发
Quick Start
快速入门
Invoke this skill when:
- Building CLI applications in any language
- Creating interactive terminal user interfaces
- Implementing command-line argument parsing
- Building shell scripts and automation tools
- Creating REPL-style applications
Do NOT invoke when:
- Building GUI desktop applications (use windows-app-developer)
- Creating web-based interfaces (use frontend skills)
- Writing PowerShell-specific tools (use powershell skills)
- Building mobile applications (use mobile-developer)
在以下场景调用此技能:
- 用任意语言构建CLI应用
- 创建交互式终端用户界面
- 实现命令行参数解析
- 构建Shell脚本与自动化工具
- 创建REPL风格的应用
请勿在以下场景调用:
- 构建GUI桌面应用(请使用windows-app-developer技能)
- 创建基于Web的界面(请使用前端技能)
- 编写PowerShell专属工具(请使用powershell技能)
- 构建移动应用(请使用mobile-developer技能)
Decision Framework
决策框架
CLI Framework Selection:
├── Node.js → Commander.js, Yargs, Oclif
├── Python → Click, Typer, argparse
├── Go → Cobra, urfave/cli
├── Rust → Clap, structopt
├── TUI needed
│ ├── Node.js → Ink, Blessed
│ ├── Python → Textual, Rich
│ ├── Go → Bubbletea, tview
│ └── Rust → Ratatui, crossterm
└── Simple script → Shell (bash/zsh)CLI Framework Selection:
├── Node.js → Commander.js, Yargs, Oclif
├── Python → Click, Typer, argparse
├── Go → Cobra, urfave/cli
├── Rust → Clap, structopt
├── TUI needed
│ ├── Node.js → Ink, Blessed
│ ├── Python → Textual, Rich
│ ├── Go → Bubbletea, tview
│ └── Rust → Ratatui, crossterm
└── Simple script → Shell (bash/zsh)Core Workflows
核心工作流程
1. CLI Application Setup
1. CLI应用搭建
- Choose framework based on language/needs
- Define command structure and subcommands
- Implement argument and option parsing
- Add input validation and help text
- Implement core command logic
- Add output formatting (JSON, table, etc.)
- Package for distribution
- 根据开发语言/需求选择框架
- 定义命令结构与子命令
- 实现参数与选项解析
- 添加输入验证与帮助文本
- 实现核心命令逻辑
- 添加输出格式化(JSON、表格等)
- 打包用于分发
2. Interactive TUI Development
2. 交互式TUI开发
- Select TUI framework
- Design screen layout and components
- Implement input handling and navigation
- Add state management
- Handle terminal resize events
- Test across different terminal emulators
- 选择TUI框架
- 设计屏幕布局与组件
- 实现输入处理与导航
- 添加状态管理
- 处理终端窗口大小调整事件
- 在不同终端模拟器中测试
3. CLI Distribution
3. CLI工具分发
- Add proper versioning
- Create man pages or help docs
- Package for target platforms
- Set up installation via package managers
- Create shell completions
- Add update mechanism
- 添加规范的版本控制
- 创建手册页或帮助文档
- 针对目标平台打包
- 配置通过包管理器安装
- 创建Shell补全脚本
- 添加更新机制
Best Practices
最佳实践
- Follow POSIX conventions for flags and arguments
- Provide both short (-v) and long (--verbose) options
- Include --help and --version flags
- Use exit codes properly (0 for success)
- Support piping and stdin input
- Add shell completion scripts
- 遵循POSIX规范设置标志与参数
- 同时提供短选项(-v)与长选项(--verbose)
- 包含--help和--version标志
- 正确使用退出码(0表示成功)
- 支持管道与标准输入
- 添加Shell补全脚本
Anti-Patterns
反模式
| Anti-Pattern | Problem | Correct Approach |
|---|---|---|
| No help text | Users can't discover commands | Add comprehensive --help |
| Silent failures | Users don't know what went wrong | Clear error messages + exit codes |
| Hard-coded paths | Breaks on other systems | Use environment variables, XDG |
| No stdin support | Can't pipe data | Support reading from stdin |
| Colored output to pipes | Breaks parsing | Detect TTY, disable colors for pipes |
| 反模式 | 问题 | 正确做法 |
|---|---|---|
| 无帮助文本 | 用户无法了解可用命令 | 添加全面的--help功能 |
| 静默失败 | 用户不知道出现了什么问题 | 清晰的错误提示 + 退出码 |
| 硬编码路径 | 在其他系统上无法正常运行 | 使用环境变量、XDG规范 |
| 不支持标准输入 | 无法通过管道传输数据 | 支持从标准输入读取内容 |
| 向管道输出彩色内容 | 导致解析失败 | 检测TTY,向管道输出时禁用彩色 |