37 lines
881 B
Rust
37 lines
881 B
Rust
use {
|
|
crate::alloc::string::ToString,
|
|
alloc::{string::String, vec::Vec},
|
|
clparse::Arguments,
|
|
core::fmt::{Debug, Display},
|
|
log::trace,
|
|
xml::XMLElement,
|
|
};
|
|
pub type BootModules = Vec<BootModule>;
|
|
|
|
pub struct BootModule {
|
|
pub path: String,
|
|
pub bytes: Vec<u8>,
|
|
pub cmd: String,
|
|
}
|
|
impl BootModule {
|
|
pub fn new(path: String, bytes: Vec<u8>, cmd: String) -> Self {
|
|
Self { path, bytes, cmd }
|
|
}
|
|
}
|
|
|
|
pub fn build_cmd<T: Display + Debug>(name: T, cmdline: T) -> XMLElement {
|
|
let mut cmdline = cmdline.to_string();
|
|
cmdline.pop();
|
|
cmdline.remove(0);
|
|
|
|
let cmd = Arguments::parse(cmdline.to_string()).unwrap();
|
|
trace!("Cmdline: {cmd:?}");
|
|
|
|
let mut clo = XMLElement::new(name);
|
|
for (key, value) in cmd.arguments {
|
|
clo.set_attribute(key, value);
|
|
}
|
|
trace!("command line object: {:?}", clo);
|
|
clo
|
|
}
|