mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 20:07:01 +05:30
main: extract clipboard logic to its own method
This commit is contained in:
parent
763c7a33b2
commit
2d4776d7d0
1 changed files with 5 additions and 1 deletions
|
@ -18,6 +18,11 @@ fn main() -> Result<()> {
|
||||||
config_path.set_extension("toml");
|
config_path.set_extension("toml");
|
||||||
let config_str = std::fs::read_to_string(config_path.as_path()).unwrap_or_default();
|
let config_str = std::fs::read_to_string(config_path.as_path()).unwrap_or_default();
|
||||||
let config: Replacements<'_> = toml::from_str(&config_str)?;
|
let config: Replacements<'_> = toml::from_str(&config_str)?;
|
||||||
|
loop_clipboard(config);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn loop_clipboard<'a>(config: Replacements<'a>) {
|
||||||
let mut clipboard: ClipboardContext =
|
let mut clipboard: ClipboardContext =
|
||||||
ClipboardProvider::new().expect("Failed to get clipboard");
|
ClipboardProvider::new().expect("Failed to get clipboard");
|
||||||
let mut clipboard_contents = get_clipboard_contents(&mut clipboard);
|
let mut clipboard_contents = get_clipboard_contents(&mut clipboard);
|
||||||
|
@ -42,7 +47,6 @@ fn main() -> Result<()> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clipboard_contents(clipboard: &mut ClipboardContext) -> Result<String, Box<dyn Error>> {
|
fn get_clipboard_contents(clipboard: &mut ClipboardContext) -> Result<String, Box<dyn Error>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue