Skip to content

Commit da6e1d6

Browse files
committed
Clean out the lint
1 parent 1f80137 commit da6e1d6

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/config.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
use crate::touch::TriggerCorner;
12
use anyhow::Result;
2-
use figment::{Figment, providers::{Env, Toml, Serialized, Format}};
3+
use figment::{
4+
providers::{Env, Format, Serialized, Toml},
5+
Figment,
6+
};
37
use serde::{Deserialize, Serialize};
4-
use crate::touch::TriggerCorner;
58

69
#[derive(Serialize, Deserialize, Debug, Clone)]
710
pub struct Config {
@@ -86,19 +89,16 @@ impl Config {
8689
let config_path = Self::config_path()?;
8790

8891
log::info!("Saving config to {:?}", config_path);
89-
let content = toml::to_string_pretty(self)
90-
.map_err(|e| anyhow::anyhow!("Failed to serialize config: {}", e))?;
92+
let content = toml::to_string_pretty(self).map_err(|e| anyhow::anyhow!("Failed to serialize config: {}", e))?;
9193

92-
std::fs::write(&config_path, content)
93-
.map_err(|e| anyhow::anyhow!("Failed to write config file {:?}: {}", config_path, e))?;
94+
std::fs::write(&config_path, content).map_err(|e| anyhow::anyhow!("Failed to write config file {:?}: {}", config_path, e))?;
9495

9596
Ok(())
9697
}
9798

9899
/// Get the config file path: ~/.ghostwriter.toml
99100
pub fn config_path() -> Result<std::path::PathBuf> {
100-
let home = std::env::var("HOME")
101-
.map_err(|_| anyhow::anyhow!("HOME environment variable not set"))?;
101+
let home = std::env::var("HOME").map_err(|_| anyhow::anyhow!("HOME environment variable not set"))?;
102102
Ok(std::path::Path::new(&home).join(".ghostwriter.toml"))
103103
}
104104

@@ -109,7 +109,7 @@ impl Config {
109109

110110
// Validate log level
111111
match self.log_level.as_str() {
112-
"error" | "warn" | "info" | "debug" | "trace" => {},
112+
"error" | "warn" | "info" | "debug" | "trace" => {}
113113
_ => return Err(anyhow::anyhow!("Invalid log level: {}", self.log_level)),
114114
}
115115

@@ -120,4 +120,4 @@ impl Config {
120120

121121
Ok(())
122122
}
123-
}
123+
}

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,16 @@ fn ghostwriter(args: &Args) -> Result<()> {
380380

381381
let prompt_general_raw = load_config(&config.prompt);
382382
let prompt_general_json = serde_json::from_str::<serde_json::Value>(prompt_general_raw.as_str())?;
383-
let prompt = prompt_general_json["prompt"].as_str()
383+
let prompt = prompt_general_json["prompt"]
384+
.as_str()
384385
.ok_or_else(|| anyhow::anyhow!("Prompt file '{}' missing required 'prompt' field", config.prompt))?;
385386

386387
let segmentation_description = if config.apply_segmentation {
387388
info!("Building image segmentation");
388389
lock!(keyboard).progress("segmenting...")?;
389-
let input_filename = config.input_png.clone()
390+
let input_filename = config
391+
.input_png
392+
.clone()
390393
.or_else(|| config.save_screenshot.clone())
391394
.ok_or_else(|| anyhow::anyhow!("Segmentation requires either --input-png or --save-screenshot to be specified"))?;
392395
match analyze_image(input_filename.as_str()) {

0 commit comments

Comments
 (0)