1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
use crate::profile::{get_profile, Profile}; use clap::{ArgMatches}; pub mod run; #[derive(Debug)] pub struct Command { pub profile: Profile, pub daemon_mode: bool, pub processes_to_run: Vec<String>, pub verbosity: String, } pub fn get_command(matches: ArgMatches) -> Command { let file: String = matches.value_of("file").unwrap_or("arpx.yaml").to_string(); let cmd_profile = match get_profile(file) { Ok(profile) => profile, Err(error) => panic!(error), }; let mut cmd_processes: Vec<String> = Vec::new(); if let Some(ref process) = matches.value_of("process") { cmd_processes.push(process.to_string()); } else { for process in cmd_profile.processes.iter() { cmd_processes.push(process.name[..].to_string()); } } let mut cmd_daemon: bool = false; if matches.is_present("daemon") { cmd_daemon = true; print!("\nNOTE: Daemon mode unstable. Feature not fully implemented yet.\n\n"); } let cmd_verbosity = match matches.occurrences_of("v") { 0 => "info".to_string(), 1 => "verbose".to_string(), 2 => "debug".to_string(), 3 | _ => "silly".to_string(), }; if cmd_verbosity != "info" { print!("\nNOTE: Verbosity level is info. Feature not implemented yet.\n\n"); } Command { profile: cmd_profile, daemon_mode: cmd_daemon, processes_to_run: cmd_processes, verbosity: cmd_verbosity, } }