From a66357a1793ba674e11298f4c6366f2a7e143ab3 Mon Sep 17 00:00:00 2001 From: primardj Date: Fri, 5 Apr 2024 22:00:23 +0100 Subject: [PATCH 1/3] check value env variable SVDIR --- 01_phase_rust_src/sv/src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/01_phase_rust_src/sv/src/main.rs b/01_phase_rust_src/sv/src/main.rs index 20097a0..944a2f1 100644 --- a/01_phase_rust_src/sv/src/main.rs +++ b/01_phase_rust_src/sv/src/main.rs @@ -7,6 +7,18 @@ use std::env; fn main() { let args: Vec = env::args().collect(); + // def env variables. + let svdir_env = env::var("SVDIR"); + //let svwait_env = env::var("SVWAIT"); + + let svdir_var = match svdir_env { + Ok(var) => var, + Err(..) => "/run/runit/service".to_string(), + }; + + dbg!(svdir_var); + + // args let arg_parser: Vec = parser::parse_args(args); From 989025fe6982d558dd5e3271230b1df2362abf27 Mon Sep 17 00:00:00 2001 From: primardj Date: Fri, 5 Apr 2024 22:10:11 +0100 Subject: [PATCH 2/3] add env var SVWAIT --- 01_phase_rust_src/sv/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/01_phase_rust_src/sv/src/main.rs b/01_phase_rust_src/sv/src/main.rs index 944a2f1..fad9b6e 100644 --- a/01_phase_rust_src/sv/src/main.rs +++ b/01_phase_rust_src/sv/src/main.rs @@ -9,14 +9,25 @@ fn main() { // def env variables. let svdir_env = env::var("SVDIR"); - //let svwait_env = env::var("SVWAIT"); + let svwait_env = env::var("SVWAIT"); let svdir_var = match svdir_env { Ok(var) => var, Err(..) => "/run/runit/service".to_string(), }; + // TODO: check if directory exists + + let svwait_var = match svwait_env { + Ok(env) => match env.parse::() { + Ok(var) => var, + Err(..) => 7, + }, + Err(..) => 7, + }; + dbg!(svdir_var); + dbg!(svwait_var); // args From 0db815879544a8ef2dca9f43b8c8857e6a6d0f1f Mon Sep 17 00:00:00 2001 From: primardj Date: Fri, 5 Apr 2024 22:19:10 +0100 Subject: [PATCH 3/3] remove an useless TODO and add three good ones. --- 01_phase_rust_src/sv/src/main.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/01_phase_rust_src/sv/src/main.rs b/01_phase_rust_src/sv/src/main.rs index fad9b6e..2304b2d 100644 --- a/01_phase_rust_src/sv/src/main.rs +++ b/01_phase_rust_src/sv/src/main.rs @@ -5,7 +5,6 @@ mod parser; use std::env; fn main() { - let args: Vec = env::args().collect(); // def env variables. let svdir_env = env::var("SVDIR"); @@ -16,8 +15,6 @@ fn main() { Err(..) => "/run/runit/service".to_string(), }; - // TODO: check if directory exists - let svwait_var = match svwait_env { Ok(env) => match env.parse::() { Ok(var) => var, @@ -30,11 +27,18 @@ fn main() { dbg!(svwait_var); - // args + // run the parser + let args: Vec = env::args().collect(); + let arg_parser: Vec = parser::parse_args(args); dbg!(arg_parser); + + // TODO: Interpret the flags given if some are given. + // TODO: Set the command if it is given + // TODO: Exec the command on all given services. + + - //dbg!(args); }