mod actions;
mod inspect;
mod issues;
use std::path::Path;
use artifactize_core::{
runtime::Verdict,
types::{RequestId, ReviewerId, RunId},
};
use clap::Subcommand;
use issues::IssuesSource;
#[derive(Debug, Subcommand)]
pub enum RequestCommand {
List {
#[arg(long, value_name = "RUN_ID")]
run: Option<RunId>,
},
Show { id: RequestId },
Logs {
id: RequestId,
#[command(flatten)]
query: artifactize_core::inspect::LogOptions,
},
Claim {
id: RequestId,
#[arg(long, value_name = "NAME")]
reviewer: Option<ReviewerId>,
},
Unclaim {
id: RequestId,
#[arg(long, value_name = "NAME")]
reviewer: Option<ReviewerId>,
},
Tool {
id: RequestId,
tool: artifactize_core::config::ToolName,
#[arg(long, value_name = "NAME")]
reviewer: Option<ReviewerId>,
},
Submit {
id: RequestId,
#[arg(long, value_enum)]
verdict: Verdict,
#[command(flatten)]
issues: IssuesSource,
#[arg(long, value_name = "NAME")]
reviewer: Option<ReviewerId>,
},
}
pub(super) async fn execute(
state: &Path,
command: RequestCommand,
json: bool,
) -> Result<u8, String> {
match command {
RequestCommand::List { run } => inspect::list(state, run, json).await?,
RequestCommand::Show { id } => inspect::show(state, &id).await?,
RequestCommand::Logs { id, query } => inspect::logs(state, id, query).await?,
RequestCommand::Claim { id, reviewer } => actions::claim(state, id, reviewer).await?,
RequestCommand::Unclaim { id, reviewer } => actions::unclaim(state, id, reviewer).await?,
RequestCommand::Tool { id, tool, reviewer } => {
return actions::tool(state, id, tool, reviewer, json).await;
}
RequestCommand::Submit {
id,
verdict,
issues,
reviewer,
} => {
actions::submit(state, id, verdict, issues, reviewer).await?;
}
}
Ok(0)
}
#[cfg(test)]
mod tests;