oparry_cli/commands/
wrap.rs1use clap::Parser;
7use oparry_core::Result;
8use std::sync::Arc;
9
10use oparry_wrapper::{ClaudeWrapper, ValidatorEngine, WrapConfig};
11
12#[derive(Parser)]
14pub struct WrapCommand {
15 #[arg(short, long)]
17 pub config: Option<String>,
18
19 #[arg(long, default_value = "false")]
21 pub warn_only: bool,
22
23 #[arg(short, long)]
25 pub verbose: bool,
26}
27
28impl WrapCommand {
29 pub fn new(config: Option<String>, warn_only: bool, verbose: bool) -> Self {
30 Self { config, warn_only, verbose }
31 }
32
33 pub fn run(self) -> Result<()> {
34 if self.verbose {
36 env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug"))
37 .init();
38 } else {
39 env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
40 .init();
41 }
42
43 let mut config = WrapConfig::default();
45 if self.warn_only {
46 config.block = false;
47 }
48
49 let validator = Arc::new(ValidatorEngine::new());
51
52 let wrapper = ClaudeWrapper::new(validator, config);
54
55 wrapper.run()
57 }
58}