From f7438b9c35734b912323b268c5a847c3b2abc2d8 Mon Sep 17 00:00:00 2001 From: Didier Date: Tue, 8 Aug 2023 01:35:09 +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![] + }, } } }