fix: no args = panic

This commit is contained in:
Strix 2023-10-14 22:39:49 +02:00
parent 497b53eb91
commit b434d086a1
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774

View file

@ -18,9 +18,20 @@ pub struct Args {
impl From<Vec<String>> for Args { impl From<Vec<String>> for Args {
fn from(value: Vec<String>) -> Self { fn from(value: Vec<String>) -> Self {
if value.len() == 0 {
return Args {
command: Command::from(String::default()),
args: vec![],
}
}
Args { Args {
command: Command::from(value[0].to_owned()), command: Command::from(value[0].to_owned()),
args: value[1..].to_owned(), args: if value.len() > 1 {
value[1..].to_owned()
} else {
vec![]
},
} }
} }
} }