mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-04-20 19:03:08 +01:00
revert to liams commit
This commit is contained in:
parent
599ad20c7a
commit
9e34347b5b
@ -111,12 +111,10 @@ fn default_true() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
enum EntryType {
|
enum EntryType {
|
||||||
#[serde(rename = "entries")]
|
|
||||||
Entries(Vec<Entry>),
|
Entries(Vec<Entry>),
|
||||||
#[serde(rename = "command")]
|
|
||||||
Command(String),
|
Command(String),
|
||||||
#[serde(rename = "script")]
|
|
||||||
Script(PathBuf),
|
Script(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,14 +130,16 @@ impl Entry {
|
|||||||
match data {
|
match data {
|
||||||
SystemDataType::Environment(var_name) => std::env::var(var_name)
|
SystemDataType::Environment(var_name) => std::env::var(var_name)
|
||||||
.is_ok_and(|var| values.contains(&var) == *matches),
|
.is_ok_and(|var| values.contains(&var) == *matches),
|
||||||
SystemDataType::File(path) => {
|
SystemDataType::ContainingFile(file) => std::fs::read_to_string(file)
|
||||||
std::fs::read_to_string(path).is_ok_and(|data| {
|
.is_ok_and(|data| {
|
||||||
values.iter().all(|matching| data.contains(matching)) == *matches
|
values
|
||||||
})
|
.iter()
|
||||||
}
|
.all(|matching| data.contains(matching) == *matches)
|
||||||
|
}),
|
||||||
SystemDataType::CommandExists => values
|
SystemDataType::CommandExists => values
|
||||||
.iter()
|
.iter()
|
||||||
.all(|command| which::which(command).is_ok() == *matches),
|
.all(|command| which::which(command).is_ok() == *matches),
|
||||||
|
SystemDataType::FileExists => values.iter().all(|p| Path::new(p).is_file()),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -157,12 +157,11 @@ struct Precondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
enum SystemDataType {
|
enum SystemDataType {
|
||||||
#[serde(rename = "environment")]
|
|
||||||
Environment(String),
|
Environment(String),
|
||||||
#[serde(rename = "file")]
|
ContainingFile(PathBuf),
|
||||||
File(PathBuf),
|
FileExists,
|
||||||
#[serde(rename = "command_exists")]
|
|
||||||
CommandExists,
|
CommandExists,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user