create module executor and pass to it all it's parametters.

This commit is contained in:
primardj 2024-04-07 19:27:08 +01:00
parent 14c01eb796
commit 7674e823b9
2 changed files with 28 additions and 14 deletions

View file

@ -0,0 +1,11 @@
pub fn execute(svdir_var: String, svwait_var: i32, verbose: i8, command: &str, services: Vec<String>){
println!("execute in exec");
dbg!(svdir_var);
dbg!(svwait_var);
dbg!(verbose);
dbg!(command);
dbg!(services);
}

View file

@ -1,5 +1,6 @@
mod parser; mod parser;
mod executor;
use std::env; use std::env;
use std::process::exit; use std::process::exit;
@ -23,10 +24,10 @@ fn main() {
Err(..) => 7, Err(..) => 7,
}; };
let mut verbose = 0; let mut verbose: i8 = 0;
dbg!(svdir_var); //dbg!(svdir_var);
dbg!(svwait_var); //dbg!(svwait_var);
// run the parser // run the parser
@ -34,18 +35,18 @@ fn main() {
let arg_parser: Vec<String> = parser::parse_args(args); let arg_parser: Vec<String> = parser::parse_args(args);
//dbg!(arg_parser);
let mut i = 0; let mut i = 0;
let mut command; let mut command = "INVALID";
let mut services: Vec<String> = Vec::new();
// make data from parser.
for val in arg_parser.iter() { for val in arg_parser.iter() {
if i == 0 { if i == 0 {
if val == "-v" { if val == "-v" {
verbose = 1; verbose = 1;
dbg!(verbose); //dbg!(verbose);
} }
else if val == "-w" { else if val == "-w" {
i = 3; i = 3;
@ -70,22 +71,24 @@ fn main() {
} }
else if i == 1 { else if i == 1 {
command = val; command = val;
dbg!(command); //dbg!(command);
i += 1; i += 1;
} }
// TODO: Exec the command on all given services. else if i == 2 {
// case services to control.
//dbg!(val);
services.push(val.to_string());
}
else if i == 3 { else if i == 3 {
svwait_var = match val.parse::<i32>() { svwait_var = match val.parse::<i32>() {
Ok(val) => val, Ok(val) => val,
Err(..) => svwait_var, Err(..) => svwait_var,
}; };
dbg!(svwait_var); //dbg!(svwait_var);
i = 0; i = 0;
} }
} }
executor::execute(svdir_var, svwait_var, verbose, command, services);
} }