Skip to content

Commit b6507c3

Browse files
committed
fix clippy warnings and add _version file
1 parent cb0a9d8 commit b6507c3

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[package]
22
name = "ghosttify"
3-
version = "0.1.0"
3+
version = "1.0.0"
44
authors = ["Nathnael (Nati) Bekele nwtbekele@gmail.com"]
55
edition = "2021"
66
readme = "README.md"
77
repository = "https://github.com/natibek/ghosttify"
8+
description = "Rust CLI tool for converting gnome-terimal shortcuts to ghostty keybindings."
89
license = "Apache 2.0"
910

1011
[dependencies]

_version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "1.0.0"

src/main.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static MAP_STRING: &str = include_str!("./gnome_to_ghostty.json");
4646
/// - gnome_to_ghostty_shortcut: A hashmap with a mapping from gnome configuration key
4747
/// representatioin to ghostty's.
4848
fn convert_gnome_shortcut_to_ghostty(
49-
gnome_shortcut: &String,
49+
gnome_shortcut: &str,
5050
gnome_to_ghostty_shortcut: &HashMap<String, String>,
5151
) -> Option<String> {
5252
let ghostty_shortcut = gnome_shortcut
@@ -58,9 +58,9 @@ fn convert_gnome_shortcut_to_ghostty(
5858
match mapped {
5959
Some(ghostty_key) => {
6060
if ghostty_key.is_empty() || ghostty_key == "disabled" {
61-
return None;
61+
None
6262
} else {
63-
return Some(ghostty_key.to_string());
63+
Some(ghostty_key.to_string())
6464
}
6565
}
6666
None => Some(key.to_string()),
@@ -102,14 +102,7 @@ fn convert_gnome_to_ghostty_shortcuts(
102102
None => return None,
103103
}
104104

105-
let ghostty_shortcut = if let Some(shortcut) =
106-
convert_gnome_shortcut_to_ghostty(binding, &gnome_to_ghostty_shortcut)
107-
{
108-
shortcut
109-
} else {
110-
return None;
111-
};
112-
105+
let ghostty_shortcut = convert_gnome_shortcut_to_ghostty(binding, gnome_to_ghostty_shortcut)?;
113106
Some((ghostty_action.unwrap().to_string(), ghostty_shortcut))
114107
})
115108
.collect()
@@ -231,7 +224,7 @@ fn update_ghostty_config(
231224

232225
let config_found: bool = io::BufReader::new(&config_file)
233226
.lines()
234-
.filter_map(Result::ok)
227+
.map_while(Result::ok)
235228
.any(|line| re.is_match(&line));
236229

237230
let gnome_shortcuts_path = ghostty_config_dir.join("gnome-shortcuts");
@@ -257,7 +250,7 @@ fn update_ghostty_config(
257250
};
258251

259252
for (action, binding) in &converted_gnome_shortcuts {
260-
if (avoid_conflict && (!ghostty_shortcuts.contains_key(action) && !keybindings.contains_key(binding))) || !avoid_conflict {
253+
if !avoid_conflict || !ghostty_shortcuts.contains_key(action) && !keybindings.contains_key(binding) {
261254
gnome_shortcuts_config
262255
.write_all(format!("keybind = {}={}\n", binding, action).as_bytes())
263256
.unwrap();
@@ -279,13 +272,13 @@ fn main() {
279272
let gnome_shortcuts = get_gnome_shortcuts();
280273
let converted_shortcuts = convert_gnome_to_ghostty_shortcuts(gnome_shortcuts);
281274

282-
if args.gnome || (!args.ghostty && !args.gnome) {
275+
if args.gnome || !args.ghostty {
283276
println!("{}", "Gnome Shortcuts".italic().bold().bright_blue());
284277
print_ghostty_shortcuts(&converted_shortcuts);
285278
}
286279

287280
let ghostty_shortcuts = get_ghostty_shortcuts();
288-
if args.ghostty || (!args.ghostty && !args.gnome) {
281+
if args.ghostty || !args.gnome {
289282
println!("{}", "Ghostty Shortcuts".italic().bold().bright_blue());
290283
print_ghostty_shortcuts(&ghostty_shortcuts);
291284
}

0 commit comments

Comments
 (0)