Skip to content

feat: use clap to accept repository and branch as arguments#229

Merged
reddevilmidzy merged 3 commits intomainfrom
use-clap
Sep 23, 2025
Merged

feat: use clap to accept repository and branch as arguments#229
reddevilmidzy merged 3 commits intomainfrom
use-clap

Conversation

@reddevilmidzy
Copy link
Owner

@reddevilmidzy reddevilmidzy commented Sep 23, 2025

♟️ What’s this PR about?

clap crate를 사용해서 실행 시 repository와 branch를 인자로 받을 수 있도록 변경하였습니다.
(기존에는 JSON으로 주고받음)

🔗 Related Issues / PRs

closes: #227, #193

Summary by CodeRabbit

  • New Features
    • Added a command-line interface to specify a repository and an optional branch for running link checks.
  • Style
    • Improved console logging format for clearer, timestamped output.
  • Chores
    • Updated dependencies and added new runtime and test dependencies to support the CLI and testing tooling.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Walkthrough

Introduces Clap v4 CLI parsing and a new Args struct to accept --repo <URL> and optional --branch <name>; replaces a hardcoded call with stream_link_checks(args.repo, args.branch). Updates dependencies in Cargo.toml (tokio, regex, adds clap, adds dev-dep wiremock).

Changes

Cohort / File(s) Summary
Dependencies
Cargo.toml
Bumped regex to 1.11, tokio to 1.47 with features = ["full"]; added clap = { version = "4.5", features = ["derive"] }; added dev-dependency wiremock = "0.6.4".
CLI integration & main flow
src/main.rs
Added Args struct deriving Parser and Debug with repo: String and branch: Option<String>; parse CLI args via Clap; replaced hardcoded invocation with stream_link_checks(args.repo, args.branch).await; retained/enhanced logger initialization and existing error handling.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning While the clap-related changes match the PR objective, Cargo.toml also includes unrelated dependency bumps (regex and tokio) and a new dev-dependency (wiremock) that are not mentioned in the PR description or required by the linked issue and therefore expand the PR scope. These dependency changes appear out of scope for simply adding CLI argument parsing. Revert or move the dependency version bumps and the new dev-dependency into a separate PR with a clear rationale, or document in this PR why those changes are necessary for the clap integration; keep the CLI change isolated if no justification exists.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change: integrating clap to accept repository and branch as command-line arguments. It matches the main code modifications in src/main.rs and the added clap dependency.
Linked Issues Check ✅ Passed The changes implement a Clap-based Args struct with repo and optional branch fields, add clap to Cargo.toml, and wire the parsed values into stream_link_checks, which satisfies issue #227's requirement to support --repo and optional --branch using clap. The implementation and added dependency align with the linked issue's objectives.
Description Check ✅ Passed The PR description includes the required template sections: "## ♟️ What’s this PR about?" with a concise summary that the clap crate is used to accept repository and branch as runtime arguments, and "## 🔗 Related Issues / PRs" which references closing issues #227 and #193; the content matches the PR objectives. The description is brief but provides the essential information and links expected by the repository template.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch use-clap

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added this to the 6차 MVP 구현 milestone Sep 23, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 68c4caf and faff94c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is 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이 자체 처리합니다.

@coveralls-official
Copy link

coveralls-official bot commented Sep 23, 2025

Pull Request Test Coverage Report for Build 17942968304

Details

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 79.911%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/main.rs 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
src/main.rs 1 0.0%
Totals Coverage Status
Change from base Build 17921389833: 0.2%
Covered Lines: 899
Relevant Lines: 1125

💛 - Coveralls

@reddevilmidzy reddevilmidzy merged commit 081feeb into main Sep 23, 2025
6 checks passed
@reddevilmidzy reddevilmidzy deleted the use-clap branch September 23, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

코드 실행 시 체크할 Repository 인자로 받기

1 participant