candycore/candy-shell
最新稳定版本:v0.2.0
Composer 安装命令:
composer require candycore/candy-shell
包简介
PHP port of charmbracelet/gum — composer-installable CLI of SugarCraft TUI primitives. 13 subcommands: choose, confirm, file, filter, format, input, join, log, pager, spin, style, table, write.
README 文档
README
CandyShell
composer require sugarcraft/candy-shell
PHP port of charmbracelet/gum — a composer-installable CLI of SugarCraft TUI primitives, useful for shell scripts.
# Apply styling. candyshell style --foreground "#ff5f87" --bold "Hello, candy!" # Pick one item. choice=$(candyshell choose Pizza Burger Salad) # Read a single line. name=$(candyshell input --placeholder "Your name?") # Confirm a destructive action. candyshell confirm "Really delete $file?" && rm "$file"
Subcommands
All 13 gum subcommands ship. Run candyshell <cmd> --help for the full
flag list per command.
| Command | Role |
|---|---|
choose |
Pick one or many items from a list. |
confirm |
Yes/no prompt — exit 0 on confirm, 1 on cancel. |
file |
Interactive file picker. |
filter |
Fuzzy filter over stdin lines (single- or multi-select). |
format |
Render Markdown / code / template / emoji to the terminal. |
input |
Read a single line; supports --password masking. |
join |
Concatenate two styled fragments side-by-side or stacked. |
log |
Levelled / structured log output (text · json · logfmt). |
pager |
Scrollable viewer for long input. |
spin |
Run an external command behind a spinner. |
style |
Apply Sprinkles styling to argv (or stdin). |
table |
Render a CSV / TSV table. |
write |
Multi-line text editor. |
Flag reference (selected highlights)
The audit lists upstream-gum flags that are not yet wired in CandyShell. The shipped surface today covers the 80 % case for shell scripts; see AUDIT_2026_05_06.md for the full delta. Common flags across commands:
--limit N/--no-limit/--ordered/--selected="a,b"— multi-select onchooseandfilter.--header "Email:"/--prompt "> "/--value "$LAST"/--char-limit N/--width N/--max-lines N/--show-line-numbersoninput/write.--affirmative "Yes"/--negative "No"/--default=yes|no/--show-outputonconfirm.--show-output/--show-errorplus 12 spinner styles (dot·line·pulse·globe·points·monkey·moon·meter·mini-dot·hamburger·ellipsis·jump) onspin.--min-level info/--prefix/--time RFC3339/--file out.log/--formatter text|json|logfmt/--structuredonlog.--border/--border-foreground "#ff0"/--height N/--trimonstyle.
Environment
CandyShell respects standard CLI colour conventions:
NO_COLOR=1disables every SGR escape — output is plain ASCII.CLICOLOR=0disables colour when stdout is not a TTY (otherwise defaults to colour).CLICOLOR_FORCE=1keeps colour even when stdout is piped or redirected.FORCE_COLOR=1|2|3forces a specific tier (16 / 256 / TrueColor).
Exit codes
0— normal completion. Forconfirm, this means the user picked the affirmative answer.1—confirmdeclined; or non-zero exit forwarded from the external command run byspin.130— interrupted (Ctrl-C / SIGINT). Matches POSIX shell convention.
Porting from gum
Most gum X invocations work as candyshell X verbatim. Known
behavioural differences (also see
AUDIT_2026_05_06.md):
formataccepts-t/--type(markdown,code,template,emoji) alongside--theme. Template support is the lightweight{{VAR}}expansion — Go template-function helpers are not implemented.--styleflags using the gum dotted form (--header.foreground,--cursor.foreground, …) are not yet wired across every command.--timeout,--show-help,--strip-ansi, and the--cursor-modeflags now accept their gum-equivalent values on every command. Where a flag is meaningless to a non-interactive command (format,join,log,style,table) it is still accepted for parity but treated as a no-op.confirm --default=yes|nois the form to use; the older--default-yesalias is preserved.
Theming and customization
Almost every interactive subcommand accepts a --style flag in
<element>.<property>=<value> form. Repeat the flag to layer
properties or target multiple elements:
candyshell choose --style "cursor.foreground=212" \ --style "selected.bold=true" \ --style "header.foreground=99" \ --header "Pick a colour" red green blue
Available properties on every element: foreground, background,
bold, italic, underline, strikethrough, faint, blink,
reverse. Element names are documented inline in each subcommand's
--help output (choose exposes cursor, header, selected,
unselected; confirm exposes prompt, selected, unselected;
input/write expose prompt, placeholder, cursor, header,
lineNumber).
Colour values accept the same surface as
CandySprinkles: hex (#ff8800),
ANSI 0–15 (9 for bright red), 8-bit (212), and named CSS colours
(coral, slategray).
Themes for format ride on
CandyShine: pass --theme dracula,
--theme tokyo-night, --theme dark, --theme light, --theme pink,
--theme ascii, or --theme notty to swap renderer presets without
authoring a Style yourself. --type code --language=go reuses the
markdown pipeline for syntax-only rendering, while --type emoji
expands the built-in :smile: shortcode set (unknown shortcodes pass
through verbatim).
The same Style rules apply to the style subcommand, which is the
canonical way to compose lipgloss-style boxes from a script:
candyshell style --foreground=212 --bold --border rounded \
--padding "1 4" --margin "0 2" "Welcome aboard"
Test
cd candy-shell && composer install && vendor/bin/phpunit
Demos
choose
Confirm
file
filter
format
Input
join
log
pager
spin
Style
Table
write
candycore/candy-shell 适用场景与选型建议
candycore/candy-shell 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cli」 「filter」 「shell」 「terminal」 「style」 「prompt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 candycore/candy-shell 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 candycore/candy-shell 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 candycore/candy-shell 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Nova searchable filter for belongsTo relationships.
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
Shell command module for PHP.
PHP library for the MUMSYS project
Symfony DataGridBundle
PHP Automation Tools
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-07












