name: ascii-progress-and-spinner description: 为命令行用户体验设计ASCII进度条和旋转器(确定性/非确定性,TTY单行刷新,非交互式日志回退),带有可复制的样式规范。 license: 完整条款在LICENSE.txt中 dependencies:
- python>=3.8
何时使用此技能
关键触发规则
- 仅当用户明确提及确切的技能名称时使用此技能:
ascii-progress-and-spinner。
触发短语包括:
- “ascii-progress-and-spinner”
- “use ascii-progress-and-spinner”
- “用 ascii-progress-and-spinner 生成 ASCII 进度条”
- “使用 ascii-progress-and-spinner 做 spinner / loading”
边界
- 不集成特定的UI框架;输出样式 + 刷新规则 + 回退协议 + 示例。
- 必须涵盖:
- 确定性进度条
- 非确定性旋转器
- 非TTY / 重定向输出回退(日志行,无回车更新)
如何使用此技能
输入
- mode (determinate | indeterminate)
- width (默认 40)
- showPercent (默认 true)
- showEta (可选)
- multiTask (可选)
- colorMode (none | ansi256, 默认 none)
输出(必需)
- progressBarStyles (>= 3)
- spinnerStyles (>= 2)
- renderRules (TTY单行刷新 vs logLines)
- fallbackRules (非交互式 / 重定向输出)
推荐渲染规则
- TTY(交互式): 单行刷新(覆盖前一行),避免日志泛滥
- Non-TTY(日志): 打印日志行(无覆盖)。每行可能包括任务名称 + 百分比。
脚本
scripts/demo.py: 进度条 + 旋转器形状的本地演示
示例
examples/styles.md
质量检查清单
- 固定宽度(百分比字段固定宽度以避免抖动)
- 日志模式是grep友好的(无覆盖)
- 提供仅ASCII的默认值(避免模糊宽度的Unicode)
关键词
English: ascii-progress-and-spinner, progress bar, spinner, loading, tty, non-interactive, log output, ascii 中文: ascii-progress-and-spinner, 进度条, Spinner, Loading, 终端, TTY, 日志降级, ASCII