cli: prompt before destructive commands, add idempotent flags, and fail fast

未关闭
#4,452 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 2 天内回复

@xue-ding-e 已经在做这个了。

开始于 2026年10月14日。

评估

难度
5/5
预计耗时
一周以上
新手友好度
40/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli

调研方向

Start with the CLI entry point at core/cli/src/main.rs:359 and the client retry defaults at core/common/src/types/args/mod.rs:384, then trace the listed command handlers and their error handling. Check existing CLI tests for prompts, flags, timeouts, and exit codes; done means the proposed behaviors work across the named commands and transports, with regression tests covering the distinctions and non-TTY behavior.

由索引模型根据 Issue 内容生成。

描述

enhancement tui

Problem

  • stream delete, stream purge, topic delete, topic purge, partition delete, segment delete, consumer-group delete, user delete, pat delete and context delete run at once, with no prompt.
  • A provisioning script cannot run twice. If a stream exists, stream create fails. If it does not exist, stream delete fails.
  • iggy ping against a stopped server returns after 10.06 s with Error: IggyClient(SdkError(CannotEstablishConnection)), a Rust debug value. The wait comes from the CLI client defaults (core/common/src/types/args/mod.rs:384): 10 retries, 1 s apart (#3903). Over WebSocket the CLI waits 60 s, and over QUIC it waits about 100 s per attempt.
  • Server down, wrong password, "not found" and "already exists" all exit with code 1, so a script cannot tell them apart.

Proposal

  • On a TTY, show what a destructive command will delete, and ask for y. Add -y, --yes to each of these commands. If stdin is not a TTY, keep the current behavior.
  • Add --if-not-exists to stream create, topic create, consumer-group create and user create. Add --if-exists to the matching delete commands and to pat delete. Treat the "already exists" or "not found" error of the server as success. A check before the call can race with another client.
  • Add --connect-timeout (for example 5s) for the connection and the login on every transport. The retries then run inside this time. The timeout also covers a login that gets no reply (#4262).
  • Print the error and its cause chain instead of the Debug value (core/cli/src/main.rs:359). The top-level Display is only a label, for example "Iggy client error".
  • Add distinct exit codes for connection, authentication, "not found" and "already exists" errors. Do not use 2 (clap usage errors) or 101 (panics).

Notes

  • A script that starts from a terminal also has a TTY on stdin, so the prompt is a breaking change for it.
  • With --if-not-exists, user create keeps the old password of an existing user. pat create gets no such flag, because it cannot print the token of an existing PAT.
  • The partition and segment commands take a count, so the new flags do not apply to them.
  • While #3735 is open, the error details stay empty. For example, the CLI prints "Stream with ID: 0 was not found." for a missing stream.
主要语言
Rust
星标
5.3k
派生
548
平均合并
2 天 20 小时
30 天内合并 PR
194

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/iggy 的其他 Issue

查看 apache/iggy 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。