From b434d086a170138bb8805821c26cadbf64124e62 Mon Sep 17 00:00:00 2001 From: Raine Date: Sat, 14 Oct 2023 22:39:49 +0200 Subject: [PATCH] fix: no args = panic --- bootpkg/src/args.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bootpkg/src/args.rs b/bootpkg/src/args.rs index 0df76c9..373830b 100644 --- a/bootpkg/src/args.rs +++ b/bootpkg/src/args.rs @@ -18,9 +18,20 @@ pub struct Args { impl From> for Args { fn from(value: Vec) -> 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![] + }, } } }