Cactus/args/
mod.rs

1use crate::{fs_manager, gracefully_exit};
2use clap::Parser;
3use log::{error, info};
4
5#[derive(Parser)]
6#[command(name = "CactusMC")]
7#[command(about = "This is the about, please change", long_about = None)]
8struct Cli {
9    /// Removes all server-related files except the server executable.
10    #[arg(short, long)]
11    remove_files: bool,
12}
13
14/// Retrieves args and initializes the argument parsing logic.
15pub fn init() {
16    let args = Cli::parse();
17    if args.remove_files {
18        if let Err(e) = fs_manager::clean_files() {
19            error!("Error(s) when cleaning files: {}", e);
20            gracefully_exit(crate::ExitCode::Failure);
21        } else {
22            info!("Successfully cleaned the files");
23            gracefully_exit(crate::ExitCode::Success);
24        }
25    }
26}