-
Notifications
You must be signed in to change notification settings - Fork 224
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 4914e88
Showing
4 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
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_execute: 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
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