use clap::{Parser, Subcommand, ValueEnum};
use crate::operations::OperationError;
use crate::reviews::VerdictValue;
pub fn failure_report(error: &OperationError) -> String {
match error {
OperationError::Invalid(failure) => failure.to_string(),
other => format!("Error: {other}"),
}
}
#[derive(Debug, Parser)]
#[command(name = "nbspec", version, about)]
pub struct Cli {
#[arg(long, global = true)]
pub notebook: Option<String>,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Create {
change_id: String,
#[arg(long)]
title: Option<String>,
},
Display {
change_id: String,
#[arg(long)]
full: bool,
},
Render {
change_id: String,
#[arg(long)]
diff: bool,
},
Merge {
change_id: String,
#[arg(long)]
force: bool,
},
Validate {
change_id: String,
},
Review {
change_id: String,
#[arg(long, default_value = "merge")]
gate: String,
#[arg(long, value_enum)]
verdict: VerdictArg,
#[arg(long, conflicts_with = "comment_file")]
comment: Option<String>,
#[arg(long)]
comment_file: Option<String>,
#[arg(long)]
reviewer: Option<String>,
},
Serve {
#[command(subcommand)]
service: ServeService,
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub enum VerdictArg {
Approve,
Revise,
}
impl From<VerdictArg> for VerdictValue {
fn from(value: VerdictArg) -> Self {
match value {
VerdictArg::Approve => VerdictValue::Approve,
VerdictArg::Revise => VerdictValue::Revise,
}
}
}
#[derive(Debug, Subcommand)]
pub enum ServeService {
Mcp,
}