1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-04 01:24:09 +02:00

add exec root option

This commit is contained in:
Robin Appelman 2025-09-16 16:03:30 +02:00
commit 6a3058888f
2 changed files with 41 additions and 13 deletions

View file

@ -25,6 +25,7 @@ pub enum HazeArgs {
filter: Option<String>,
service: Option<ExecService>,
command: Vec<String>,
root: bool,
},
Occ {
filter: Option<String>,
@ -180,11 +181,20 @@ impl HazeArgs {
_ => None,
};
let root = match args.peek() {
Some(arg) if arg.as_ref() == "root" => {
args.next();
true
}
_ => false,
};
let command = args.map(S::into).collect();
Ok(HazeArgs::Exec {
filter,
service,
command,
root,
})
}
HazeCommand::Occ => Ok(HazeArgs::Occ {
@ -508,6 +518,20 @@ fn test_arg_parse() {
filter: None,
service: None,
command: vec!["foo".to_string(), "bar".to_string()],
root: false,
}
);
assert_eq!(
HazeArgs::parse(
&config,
vec!["haze", "exec", "root", "foo", "bar"].into_iter()
)
.unwrap(),
HazeArgs::Exec {
filter: None,
service: None,
command: vec!["foo".to_string(), "bar".to_string()],
root: true,
}
);
assert_eq!(
@ -520,6 +544,7 @@ fn test_arg_parse() {
filter: Some("asdasd".to_string()),
service: None,
command: vec!["foo".to_string(), "bar".to_string()],
root: false,
}
);
assert_eq!(
@ -532,6 +557,7 @@ fn test_arg_parse() {
filter: Some("asdasd".to_string()),
service: Some(ExecService::Db),
command: vec!["foo".to_string(), "bar".to_string()],
root: false,
}
);
assert_eq!(