forked from ChrisTitusTech/linutil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add automation based on config file
- Loading branch information
1 parent
79eb752
commit 742ed1a
Showing
5 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use serde::Deserialize; | ||
use std::path::Path; | ||
use std::process; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Config { | ||
pub auto_select: Vec<String>, | ||
} | ||
|
||
impl Config { | ||
pub fn from_file(path: &Path) -> Self { | ||
let content = match std::fs::read_to_string(path) { | ||
Ok(content) => content, | ||
Err(e) => { | ||
eprintln!("Failed to read config file {}: {}", path.display(), e); | ||
process::exit(1); | ||
} | ||
}; | ||
|
||
match toml::from_str(&content) { | ||
Ok(config) => config, | ||
Err(e) => { | ||
eprintln!("Failed to parse config file: {}", e); | ||
process::exit(1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters