Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Deduplicate the `--yes`/non-interactive-terminal refusal guard (three near-identical copies)

Đang mở Phù hợp với người mới
#780 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Đọc ba vị trí gọi trong apps/rocm/src/uninstall.rs, apps/rocm/src/storage.rs (approved()), và apps/rocm/src/runtimes_cmd.rs, sau đó kiểm tra nhóm CLI trong AGENTS.md để tìm các thành phần UI dùng chung. Thêm guard dùng chung và cập nhật các vị trí gọi đó, giữ nguyên tên hành động và cách diễn đạt lỗi riêng biệt; ghi lại helper trong AGENTS.md. Hoàn tất khi cả ba đều dùng helper và therock.rs vẫn giữ hành vi phê duyệt riêng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement ux-opportunities

Three call sites hand-roll the same guard before a mutating action that needs a terminal to confirm in, each re-deriving: check yes/--yes first, then interactive_terminal(), then bail with the same wording template parameterized only by the action name:

  • apps/rocm/src/uninstall.rs:76-77 — if !interactive_terminal() { bail!("uninstall requires --yes outside an interactive terminal"); }
  • apps/rocm/src/storage.rs:883-884 (approved()) — if !interactive_terminal() { bail!("{action} requires --yes outside an interactive terminal"); }
  • apps/rocm/src/runtimes_cmd.rs:192-193 — if !interactive_terminal() { bail!("runtimes uninstall requires --yes outside an interactive terminal"); }

A natural shared helper collapses this into one place, e.g. something like fn require_yes_or_interactive(yes: bool, action: &str) -> Result<bool> returning whether to proceed and raising the same "requires --yes outside an interactive terminal" error with the caller's action name — so a fourth call site reaches for it instead of re-deriving the pattern again.

Deliberately excluding apps/rocm/src/therock.rs's sdk_install_approval/refuse_non_interactive_message: that non-interactive refusal is intentionally richer (it names --approve-replacing-active-default vs --yes specifically, since the two consents aren't interchangeable there), and collapsing it into the generic wording would lose that distinction — not a candidate for this helper.

Surfaced while scoping #769 (deduplicating the [y/N] prompt itself) — same audit family, filed separately since it's an independent call-site pattern rather than the prompt helper itself.

Documentation: once this lands, add a bullet for the new guard helper to AGENTS.md's "Shared UI components" section (CLI group), alongside the [y/N] prompt helper from #769.

Ngôn ngữ chính
Rust
Star
49
Fork
14
Merge trung bình
3 ngày 11 giờ
Pull request đã merge (30 ngày)
174

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ROCm/rocm-cli

Tất cả issue của ROCm/rocm-cli

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.