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:
parent
242cf54a74
commit
6a3058888f
2 changed files with 41 additions and 13 deletions
26
src/args.rs
26
src/args.rs
|
|
@ -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!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue