Compare commits

..

No commits in common. "9ec956a049d6c8df4696f1c886f5969312a81eae" and "f7504ac0418945ec1caed5ecc1fae076698f584d" have entirely different histories.

2 changed files with 7 additions and 51 deletions

View file

@ -1,8 +1,8 @@
//mod misc;
mod parser; mod parser;
use std::env; use std::env;
use std::process::exit;
fn main() { fn main() {
@ -15,7 +15,7 @@ fn main() {
Err(..) => "/run/runit/service".to_string(), Err(..) => "/run/runit/service".to_string(),
}; };
let mut svwait_var = match svwait_env { let svwait_var = match svwait_env {
Ok(env) => match env.parse::<i32>() { Ok(env) => match env.parse::<i32>() {
Ok(var) => var, Ok(var) => var,
Err(..) => 7, Err(..) => 7,
@ -23,8 +23,6 @@ fn main() {
Err(..) => 7, Err(..) => 7,
}; };
let mut verbose = 0;
dbg!(svdir_var); dbg!(svdir_var);
dbg!(svwait_var); dbg!(svwait_var);
@ -34,52 +32,12 @@ fn main() {
let arg_parser: Vec<String> = parser::parse_args(args); let arg_parser: Vec<String> = parser::parse_args(args);
//dbg!(arg_parser); dbg!(arg_parser);
// TODO: Interpret the flags given if some are given.
let mut i = 0; // TODO: Set the command if it is given
let mut command;
for val in arg_parser.iter() {
if i == 0 {
if val == "-v" {
verbose = 1;
dbg!(verbose);
}
else if val == "-w" {
i = 3;
// take next parametter before returning to i = 0.
}
else if val == "--" {
i += 1;
}
else {
if val.len() == 2 {
println!("sv: illegal option -- {}", val.chars().nth(1).unwrap() );
// TODO: thread NOT pannic if it is not an ASCII character.
}
parser::misc::usage();
exit(100);
}
}
else if i == 1 {
command = val;
dbg!(command);
i += 1;
}
// TODO: Exec the command on all given services. // TODO: Exec the command on all given services.
else if i == 3 {
svwait_var = match val.parse::<i32>() {
Ok(val) => val,
Err(..) => svwait_var,
};
dbg!(svwait_var);
i = 0;
}
}

View file

@ -1,6 +1,6 @@
pub mod misc; mod misc;
use std::process::exit; use std::process::exit;
@ -18,7 +18,6 @@ pub fn parse_args(args: Vec<String>) -> Vec<String>{
tmpstr = parse_args_1(arg); tmpstr = parse_args_1(arg);
if tmpstr == "--" { if tmpstr == "--" {
parser.push("--".to_string());
i += 1; i += 1;
} }
if tmpstr == "-w" { if tmpstr == "-w" {
@ -31,7 +30,6 @@ pub fn parse_args(args: Vec<String>) -> Vec<String>{
} }
else if tmpstr == "" { else if tmpstr == "" {
// We are actually in phase II. Do exactly the same if it was phase II. // We are actually in phase II. Do exactly the same if it was phase II.
parser.push("--".to_string());
parser.push(phase2(arg)); parser.push(phase2(arg));
i = 3; i = 3;
} }