feat: use clap to accept repository and branch as arguments#229
feat: use clap to accept repository and branch as arguments#229reddevilmidzy merged 3 commits intomainfrom
Conversation
WalkthroughIntroduces Clap v4 CLI parsing and a new Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant CLI as main.rs (CLI)
participant Logger
participant Checker as stream_link_checks
User->>CLI: Run with --repo <URL> [--branch <name>]
CLI->>CLI: clap::Parser::parse() -> Args
CLI->>Logger: initialize structured logger (format + timer)
CLI->>Checker: stream_link_checks(args.repo, args.branch).await
alt success
Checker-->>CLI: streamed results
CLI-->>User: log/output results
else error
Checker-->>CLI: error
CLI-->>User: log error & exit
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
Cargo.toml (1)
27-27: 버전 핀으로 재현성 개선 제안패치/마이너 변동에 따른 잠재적 빌드 차이를 줄이려면 마이너 버전까지 고정하는 것을 추천합니다.
-clap = { version = "4", features = ["derive"] } +clap = { version = "4.5", features = ["derive"] }src/main.rs (2)
5-12: CLI UX 소폭 개선 제안: 짧은 옵션/버전/도움말 품질현재도 동작에는 문제 없습니다. 다만 사용성 향상을 위해 다음을 권장합니다.
- -r/-b 단축 옵션 제공
- 버전/작성자 자동 노출
- 값 이름 명시로 도움말 가독성 개선
-#[derive(Debug, Parser)] -#[command(name = "queensac", about = "Link checker for a GitHub repo")] +#[derive(Debug, Parser)] +#[command(name = "queensac", about = "Link checker for a GitHub repo", version, author)] struct Args { - #[arg(long = "repo", help = "GitHub repository URL")] + #[arg(long, short = 'r', value_name = "REPO_URL", help = "GitHub repository URL")] repo: String, - #[arg(long = "branch", help = "Target branch to check")] + #[arg(long, short = 'b', value_name = "BRANCH", help = "Target branch to check")] branch: Option<String>, }추가로, 유효한 URL 강제(parsing)는 추후에 url::Url 타입으로 전환하거나 value_parser를 붙이는 방식으로 확장 가능.
README에 사용 예시(--repo, --branch) 업데이트도 필요하면 말씀 주세요. 반영 PR 초안 드릴 수 있습니다.
35-39: 에러 시 비-제로 종료 코드 반환 제안현재는 실패해도 프로세스가 0으로 종료될 수 있습니다. CLI/CI 친화성을 위해 실패 시 코드 1 반환을 권장합니다.
rt.block_on(async { - if let Err(e) = stream_link_checks(args.repo, args.branch).await { - error!("Failed to stream link checks: {}", e); - } + if let Err(e) = stream_link_checks(args.repo, args.branch).await { + error!("Failed to stream link checks: {}", e); + std::process::exit(1); + } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
Cargo.toml(1 hunks)src/main.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: reddevilmidzy
PR: reddevilmidzy/queensac#226
File: src/main.rs:21-32
Timestamp: 2025-09-22T15:50:19.531Z
Learning: User reddevilmidzy prefers to communicate in Korean and likes to keep PR scope focused and well-defined.
🧬 Code graph analysis (1)
src/main.rs (1)
src/link_checker/sse.rs (1)
stream_link_checks(79-158)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (4)
Cargo.toml (1)
27-27: clap 의존성 추가 LGTM목표와 일치합니다.
src/main.rs (3)
1-1: clap 파서 임포트 LGTM문맥에 맞게 최소 임포트 구성입니다.
3-3: tracing 임포트 LGTM필요한 심볼만 임포트되어 간결합니다.
28-28: 인자 파싱 타이밍 적절로거 초기화 후 파싱해도 문제 없고, 헬프/버전 플래그는 clap이 자체 처리합니다.
Pull Request Test Coverage Report for Build 17942968304Details
💛 - Coveralls |
♟️ What’s this PR about?
clap crate를 사용해서 실행 시 repository와 branch를 인자로 받을 수 있도록 변경하였습니다.
(기존에는 JSON으로 주고받음)
🔗 Related Issues / PRs
closes: #227, #193
Summary by CodeRabbit