mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-15 00:47:01 +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
11
rustfmt.toml
11
rustfmt.toml
|
@ -1,11 +0,0 @@
|
|||
comment_width = 80
|
||||
group_imports = "StdExternalCrate"
|
||||
imports_granularity = "Module"
|
||||
max_width = 80
|
||||
newline_style = "Unix"
|
||||
normalize_comments = true
|
||||
normalize_doc_attributes = true
|
||||
reorder_impl_items = true
|
||||
tab_spaces = 2
|
||||
version = "Two"
|
||||
wrap_comments = true
|
|
@ -6,8 +6,7 @@ use tracing::{debug, error};
|
|||
|
||||
pub fn monitor(config: &Replacements) -> Result<()> {
|
||||
loop {
|
||||
let mut clipboard =
|
||||
ClipboardContext::new().expect("Failed to get clipboard");
|
||||
let mut clipboard = ClipboardContext::new().expect("Failed to get clipboard");
|
||||
if let Ok(contents) = clipboard.get_contents() {
|
||||
if let Some(subst) = config
|
||||
.substitutors
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use anyhow::{bail, Result};
|
||||
use regex::Regex;
|
||||
use serde_derive::Deserialize;
|
||||
use tracing::trace;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
use tracing::Level;
|
||||
use tracing::dispatcher::SetGlobalDefaultError;
|
||||
use tracing::subscriber::set_global_default;
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::filter::Targets;
|
||||
|
||||
#[cfg(not(feature = "journald"))]
|
||||
fn configure_tracing(filter: Targets) -> Result<(), SetGlobalDefaultError> {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::{Layer, fmt};
|
||||
use tracing_subscriber::{fmt, Layer};
|
||||
|
||||
let stdout_log = fmt::layer().pretty();
|
||||
let subscriber =
|
||||
tracing_subscriber::registry().with(stdout_log.with_filter(filter));
|
||||
let subscriber = tracing_subscriber::registry().with(stdout_log.with_filter(filter));
|
||||
set_global_default(subscriber)
|
||||
}
|
||||
|
||||
|
@ -24,7 +23,6 @@ fn configure_tracing(filter: Targets) -> Result<(), SetGlobalDefaultError> {
|
|||
}
|
||||
|
||||
pub fn init() -> Result<(), SetGlobalDefaultError> {
|
||||
let tracing_filter =
|
||||
Targets::new().with_target("clipboard_subsitutor", Level::DEBUG);
|
||||
let tracing_filter = Targets::new().with_target("clipboard_subsitutor", Level::DEBUG);
|
||||
configure_tracing(tracing_filter)
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -21,8 +21,7 @@ fn main() -> Result<()> {
|
|||
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_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)
|
||||
|
@ -46,8 +45,7 @@ fn print_version() {
|
|||
}
|
||||
|
||||
fn get_config_path() -> Result<PathBuf> {
|
||||
let mut config_path =
|
||||
config_dir().ok_or_else(|| anyhow!("Failed to get config dir"))?;
|
||||
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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue