1use std::path::PathBuf;
4
5use clap::Parser;
6
7#[derive(Parser, Debug)]
9#[command(name = "srt")]
10#[command(about = "Sandbox Runtime - enforce filesystem and network restrictions on processes")]
11#[command(version)]
12pub struct Cli {
13 #[arg(short = 'd', long = "debug")]
15 pub debug: bool,
16
17 #[arg(short = 's', long = "settings")]
19 pub settings: Option<PathBuf>,
20
21 #[arg(short = 'c')]
23 pub command: Option<String>,
24
25 #[arg(trailing_var_arg = true)]
27 pub args: Vec<String>,
28}
29
30impl Cli {
31 pub fn parse_args() -> Self {
33 Cli::parse()
34 }
35
36 pub fn get_command(&self) -> Option<(String, bool)> {
41 if let Some(ref cmd) = self.command {
42 Some((cmd.clone(), true))
43 } else if !self.args.is_empty() {
44 let cmd = crate::utils::join_args(&self.args);
46 Some((cmd, false))
47 } else {
48 None
49 }
50 }
51
52 pub fn get_settings_path(&self) -> Option<PathBuf> {
54 self.settings.clone().or_else(crate::config::default_settings_path)
55 }
56}