fix: no args = panic
This commit is contained in:
parent
b2cd8986d0
commit
f7438b9c35
1 changed files with 12 additions and 1 deletions
|
@ -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![]
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue