[Bug] `text` validate function for text when value is empty with default value
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- node.js, typescript
- 领域
- cli
调研方向
从 core/prompts/text 开始,并使用链接的 StackBlitz 示例重现空输入情况。结合两个拟议的修复方向,审查 PR #396 草案。完成的标准是:在配置了默认值的情况下按下 Enter 会使验证使用该默认值,同时保留文档中所述的文本提示行为。
由索引模型根据 Issue 内容生成。
描述
Environment
- OS: macOS
- Node Version:
22.5.1 - Package:
@clack/promts - Package Version: 0.11.0
Describe the bug
When calling the text's validate function without user input but with a default value defined, it should use the default value instead of relying solely on user input.
To Reproduce
Steps to reproduce the behavior:
- Open repro link
- Run
node index.js - Don't type anything, just press
[Enter] - See behavior described on terminal
Expected behavior
Clear use case example:
CLI dev creates a text step for user to enter a path as input. There's some predefined value that CLI dev established to be the default use case for most users, but still allowing for that value to be changed.
Currently, the user would have to type/copy that entire path, causing a terrible user experience.
Fix Recommendation (starting a convo)
I see 2 possible ways to fix this:
- Keep
validateas is and add a check to the value oncore/prompts/text- link to draft PR - Add a second optional argument, which would be the default value to
validate. That way, Devs would have another quick option when using thevalidatefunction, without adding extra checks to thecorelibrary.
My goal with this section is to start a conversation and introduce my ideas about this issue, not a way for me to impose how I think things should be.
This would be my first contribution, so I'm pretty new here. Let me know what you think and hopefully let's get this fixed!
- 主要语言
- TypeScript
- 星标
- 8.1k
- 派生
- 218
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bombshell-dev/clack 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 70/100
bombshell-dev/clack#613 · 4 条评论 ·
-
难度 5/5 一周以上 新手友好度 30/100
bombshell-dev/clack#597 ·
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
bombshell-dev/clack#585 · 1 条评论 · 1 个 reaction ·
-
[Bug] Spinner does not run `onCancel` function on `Ctrl + C`可能已有人在做 @cyphercodes 于 101 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 68/100
bombshell-dev/clack#573 · 1 条评论 · 2 个 reaction ·
-
enhancement
难度 3/5 1-2 天 新手友好度 62/100
bombshell-dev/clack#565 · 1 条评论 · 1 个 reaction ·
查看 bombshell-dev/clack 的全部 Issue
相似的 Issue
-
effort:S priority:P2
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
dam-agents/dam#4562 ·
维护者通常 1 天内回复
-
bug p3 triaged
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
bug javascript P2-medium python release:v3.1
难度 2/5 1-3 小时 新手友好度 68/100
adrirubio/claude-deck#546 ·
维护者通常 1 天内回复