Skip to content

Commit 3272e7b

Browse files
ref(review): Use derive API and hide command from help
Convert review command to use clap's derive API pattern with ReviewArgs struct and add to SentryCLICommand enum. Hide the command from help text since it's experimental. Co-Authored-By: Claude <[email protected]>
1 parent a102347 commit 3272e7b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/commands/derive_parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clap::{ArgAction::SetTrue, Parser, Subcommand};
44

55
use super::dart_symbol_map::DartSymbolMapArgs;
66
use super::logs::LogsArgs;
7+
use super::review::ReviewArgs;
78

89
#[derive(Parser)]
910
pub(super) struct SentryCLI {
@@ -35,4 +36,6 @@ pub(super) struct SentryCLI {
3536
pub(super) enum SentryCLICommand {
3637
Logs(LogsArgs),
3738
DartSymbolMap(DartSymbolMapArgs),
39+
#[command(hide = true)]
40+
Review(ReviewArgs),
3841
}

src/commands/review/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! This module implements the `sentry-cli review` command for AI-powered code review.
22
33
use anyhow::{bail, Context as _, Result};
4-
use clap::{ArgMatches, Command};
4+
use clap::{ArgMatches, Args, Command, Parser as _};
55
use console::style;
66
use git2::{Diff, DiffOptions, Repository};
77

8+
use super::derive_parser::{SentryCLI, SentryCLICommand};
89
use crate::api::{Api, ReviewPrediction, ReviewRequest, ReviewResponse};
910
use crate::utils::vcs::git_repo_remote_url;
1011

@@ -20,11 +21,19 @@ The base commit must be pushed to the remote repository.";
2021
/// Maximum diff size in bytes (500 KB)
2122
const MAX_DIFF_SIZE: usize = 500 * 1024;
2223

24+
#[derive(Args)]
25+
#[command(about = ABOUT, long_about = LONG_ABOUT, hide = true)]
26+
pub(super) struct ReviewArgs;
27+
2328
pub(super) fn make_command(command: Command) -> Command {
24-
command.about(ABOUT).long_about(LONG_ABOUT)
29+
ReviewArgs::augment_args(command)
2530
}
2631

2732
pub(super) fn execute(_: &ArgMatches) -> Result<()> {
33+
let SentryCLICommand::Review(ReviewArgs) = SentryCLI::parse().command else {
34+
unreachable!("expected review command");
35+
};
36+
2837
eprintln!(
2938
"{}",
3039
style("[EXPERIMENTAL] This feature is in development.").yellow()

0 commit comments

Comments
 (0)