fix: no args = panic

This commit is contained in:
Didier Slof 2023-08-08 01:35:09 +02:00
parent b2cd8986d0
commit f7438b9c35
Signed by: didier
GPG key ID: 01E71F18AA4398E5

View file

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