fix: add Status() health check and SilenceUsage for baidu-cli and google-cli#10
Conversation
…amps
Bug 1: baidu-cli missing SilenceUsage/SilenceErrors
- All other CLIs (google, nanobanana, chatgpt) set these flags so cobra
doesn't print usage text on error, which would pollute the JSON output.
- baidu-cli was the only one missing it.
Bug 2: baidu-cli and google-cli missing Status() health check
- nanobanana-cli and chatgpt-image-cli call client.Status() before
operations to check daemon + extension readiness, giving friendly
error messages like 'daemon not running' or 'extension not connected'.
- baidu-cli and google-cli just jumped into operations, producing
confusing 'daemon unreachable' errors with no guidance.
- Added browser.Status struct and Status() method to both CLIs, matching
the existing pattern from nanobanana/chatgpt.
- Added pre-flight checks to baidu-cli search, google-cli search, and
google-cli result commands.
Bug 3: second-precision timestamps cause silent file overwrites
- nanobanana-cli and chatgpt-image-cli used time.Format("20060102-150405")
(second precision) for output filenames.
- Two calls within the same second would silently overwrite the first file.
- Changed to "20060102-150405.000" (millisecond precision).
|
谢谢 @RachelXiaolan 的 PR!整体方向很好,都是不错的一致性改进。合入前有几个点想和你一起讨论一下: 想确认 / 调整的点
一个建议:拆成两个 PR这个 PR 其实打包了三件正交的事:
前两个是安全的一致性改进,可以保持在一起。第三个是文件名格式的破坏性变更,建议单独发一个 PR,描述里明确写上"breaking change"。这样万一有下游用户报告文件名问题,回滚也方便,review 也更快。 觉得做得好的地方
期待 v2! |
The dot in '20060102-150405.000' looks like a file extension (e.g. '20260519-143022.123-full.png'), which can confuse shell glob patterns and downstream scripts. Changed to hyphen: '20060102-150405-000' → '20260519-143022-123-full.png'.
|
感谢详细的 review!逐条回复: 1. Navigate 签名确认过了,我没有改动 2. 时间戳分隔符同意,已改为 3. google-cli SilenceUsage你说得对,google-cli 两个子命令已经设了 SilenceUsage。rebase 后 diff 会更干净。等时间戳 PR 拆出去后我会 rebase。 拆分 PR同意你的建议。我准备:
马上拆。 |
Summary
Two consistency fixes for baidu-cli and google-cli. Timestamp changes have been moved to a separate PR (#16).
Fix 1: baidu-cli missing SilenceUsage / SilenceErrors
All other CLIs (google-cli, nanobanana-cli, chatgpt-image-cli) set
SilenceUsage = trueandSilenceErrors = trueon their cobra commands so that cobra doesn't print usage text alongside the structured JSON error output. baidu-cli was the only one missing these flags, causing it to print an extraUsage:block on every error.Fix: Added
SilenceUsageandSilenceErrorsto baidu-cli's search command.Fix 2: baidu-cli and google-cli missing Status() health check
nanobanana-cli and chatgpt-image-cli call
client.Status()before operations to verify that the kimi-webbridge daemon is running and the Chrome extension is connected. This gives users friendly, actionable error messages like:{"ok":false,"error":{"code":"daemon_not_running","message":"kimi-webbridge daemon is not running (open the Kimi Desktop App)"}}baidu-cli and google-cli skipped this check entirely. When the daemon wasn't running, they produced a raw
"daemon unreachable"error with no guidance on what to do.Fix:
Statusstruct andStatus()method tobaidu-cli/browser/client.goandgoogle-cli/browser/client.go(matching the existing implementation in nanobanana/chatgpt).search, google-clisearch, google-cliresult.Changes from previous version
go buildTesting
All affected CLIs compile successfully: