mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-15 10:07:00 +05:30
chore: revert to default formatting style
This commit is contained in:
parent
142676ac1d
commit
6048f7a537
6 changed files with 169 additions and 185 deletions
58
src/main.rs
58
src/main.rs
|
@ -6,7 +6,7 @@ mod test;
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::{Result, anyhow, bail};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use dirs::config_dir;
|
||||
use tracing::debug;
|
||||
|
||||
|
@ -14,43 +14,41 @@ use crate::clipboard::monitor;
|
|||
use crate::config::Replacements;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
if check_for_version_arg() {
|
||||
return Ok(());
|
||||
}
|
||||
if let Err(e) = logging::init() {
|
||||
bail!(e)
|
||||
};
|
||||
let config_path = get_config_path()?;
|
||||
let config_str =
|
||||
std::fs::read_to_string(config_path.as_path()).unwrap_or_default();
|
||||
let config: Replacements = toml::from_str(&config_str)?;
|
||||
config.validate()?;
|
||||
monitor(&config)
|
||||
if check_for_version_arg() {
|
||||
return Ok(());
|
||||
}
|
||||
if let Err(e) = logging::init() {
|
||||
bail!(e)
|
||||
};
|
||||
let config_path = get_config_path()?;
|
||||
let config_str = std::fs::read_to_string(config_path.as_path()).unwrap_or_default();
|
||||
let config: Replacements = toml::from_str(&config_str)?;
|
||||
config.validate()?;
|
||||
monitor(&config)
|
||||
}
|
||||
|
||||
fn check_for_version_arg() -> bool {
|
||||
for arg in argv::iter() {
|
||||
if arg == "-v" || arg == "version" || arg == "--version" {
|
||||
print_version();
|
||||
return true;
|
||||
for arg in argv::iter() {
|
||||
if arg == "-v" || arg == "version" || arg == "--version" {
|
||||
print_version();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
false
|
||||
}
|
||||
|
||||
fn print_version() {
|
||||
println!(
|
||||
"{}",
|
||||
concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION"))
|
||||
);
|
||||
println!(
|
||||
"{}",
|
||||
concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION"))
|
||||
);
|
||||
}
|
||||
|
||||
fn get_config_path() -> Result<PathBuf> {
|
||||
let mut config_path =
|
||||
config_dir().ok_or_else(|| anyhow!("Failed to get config dir"))?;
|
||||
config_path.push("substitutor");
|
||||
config_path.push("config");
|
||||
config_path.set_extension("toml");
|
||||
debug!("Config file: {}", config_path.to_string_lossy());
|
||||
Ok(config_path)
|
||||
let mut config_path = config_dir().ok_or_else(|| anyhow!("Failed to get config dir"))?;
|
||||
config_path.push("substitutor");
|
||||
config_path.push("config");
|
||||
config_path.set_extension("toml");
|
||||
debug!("Config file: {}", config_path.to_string_lossy());
|
||||
Ok(config_path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue