solve panicking with flag é
This commit is contained in:
parent
9ec956a049
commit
14c01eb796
2 changed files with 12 additions and 5 deletions
|
@ -55,9 +55,14 @@ fn main() {
|
|||
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.
|
||||
if val.len() >= 2 {
|
||||
let mut j = 0;
|
||||
for ch in val.chars() {
|
||||
if j == 1 {
|
||||
println!("sv: illegal option -- {}", ch );
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
parser::misc::usage();
|
||||
exit(100);
|
||||
|
|
|
@ -52,6 +52,7 @@ pub fn parse_args(args: Vec<String>) -> Vec<String>{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
|
@ -79,12 +80,13 @@ pub fn parse_args_1(arg: &String) -> String{
|
|||
//println!("{}", ch1);
|
||||
|
||||
if ch1 == '-' && arg.len() >= 2{
|
||||
return (&arg[..2]).to_string()
|
||||
let retour = &arg.chars().collect::<Vec<_>>()[..2];
|
||||
return retour.into_iter().collect();
|
||||
} else if ch1 == '-' {
|
||||
return ch1.to_string()
|
||||
}
|
||||
|
||||
println!("{}",arg);
|
||||
//println!("{}",arg);
|
||||
return "".to_string()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue