embargo_cpp/cli/
args.rs

1#![allow(unused)]
2
3use crate::cli::Commands;
4use clap::Parser;
5
6#[derive(Parser, Debug)]
7#[command(version, about, long_about = None)]
8pub struct Args {
9    #[command(subcommand)]
10    command: Commands,
11
12    /// Manually set the logging level
13    #[arg(long)]
14    debug_log: bool,
15}
16
17impl Args {
18    pub fn read_file(&self) -> bool {
19        !matches!(self.command, Commands::Init | Commands::New(_))
20    }
21
22    pub fn debug_new(project_name: &str) -> Self {
23        let command = Commands::debug_new(project_name);
24        let debug_log = false;
25        Self { command, debug_log }
26    }
27
28    pub fn debug_build() -> Self {
29        let command = Commands::debug_build();
30        let debug_log = false;
31        Self { command, debug_log }
32    }
33
34    /// Returns a reference to the parsed subcommand.
35    pub fn command(&self) -> &Commands {
36        &self.command
37    }
38
39    /// Returns whether debug logging was requested.
40    pub fn debug_log(&self) -> bool {
41        self.debug_log
42    }
43}
44