Skip to content

Commit 8c55274

Browse files
committed
chore: add hk config and run cargo fmt
1 parent e4a52f9 commit 8c55274

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
1717
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2
18-
- run: cargo clippy -- -D warnings
19-
- run: cargo fmt -- --check
18+
- run: hk check --all
2019
- run: cargo test --lib --tests

hk.pkl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
amends "package://github.com/jdx/hk/releases/download/v1.19.0/[email protected]#/Config.pkl"
2+
import "package://github.com/jdx/hk/releases/download/v1.19.0/[email protected]#/Builtins.pkl"
3+
4+
local linters = new Mapping<String, Step> {
5+
["cargo-fmt"] = Builtins.cargo_fmt
6+
["cargo-clippy"] = (Builtins.cargo_clippy) {
7+
check = "cargo clippy -- -D warnings"
8+
fix = "cargo clippy --fix --allow-dirty -- -D warnings"
9+
}
10+
}
11+
12+
hooks {
13+
["pre-commit"] {
14+
fix = true // automatically modify files with available linter fixes
15+
stash = "git" // stashes unstaged changes while running fix steps
16+
steps = linters
17+
}
18+
// instead of pre-commit, you can instead define pre-push hooks
19+
["pre-push"] {
20+
steps = linters
21+
}
22+
// "fix" and "check" are special steps for `hk fix` and `hk check` commands
23+
["fix"] {
24+
fix = true
25+
steps = linters
26+
}
27+
["check"] {
28+
steps = linters
29+
}
30+
}

mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tools]
22
"cargo:git-cliff" = "2.7"
33
"cargo:cargo-release" = "0.25"
4+
hk = "latest"
45

56
[tasks.changelog]
67
description = "Generate changelog"

src/confirm.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ impl<'a> Confirm<'a> {
107107
// If not a TTY (e.g., piped input or non-interactive environment),
108108
// write a simple prompt and read from stdin
109109
if !crate::tty::is_tty() {
110-
let affirmative_char = self.affirmative.to_lowercase().chars().next().unwrap_or('y');
110+
let affirmative_char = self
111+
.affirmative
112+
.to_lowercase()
113+
.chars()
114+
.next()
115+
.unwrap_or('y');
111116
let negative_char = self.negative.to_lowercase().chars().next().unwrap_or('n');
112117
let prompt = format!(
113118
"{} / {} [{}/{}]: ",
@@ -138,7 +143,12 @@ impl<'a> Confirm<'a> {
138143

139144
let ctrlc_handle = ctrlc::show_cursor_after_ctrlc(&self.term)?;
140145

141-
let affirmative_char = self.affirmative.to_lowercase().chars().next().unwrap_or('y');
146+
let affirmative_char = self
147+
.affirmative
148+
.to_lowercase()
149+
.chars()
150+
.next()
151+
.unwrap_or('y');
142152
let negative_char = self.negative.to_lowercase().chars().next().unwrap_or('n');
143153
self.term.clear_line()?;
144154
self.term.hide_cursor()?;
@@ -227,7 +237,12 @@ impl<'a> Confirm<'a> {
227237
writeln!(out, "\n")?;
228238

229239
let mut help_keys = vec![("←/→", "toggle")];
230-
let affirmative_char = self.affirmative.to_lowercase().chars().next().unwrap_or('y');
240+
let affirmative_char = self
241+
.affirmative
242+
.to_lowercase()
243+
.chars()
244+
.next()
245+
.unwrap_or('y');
231246
let negative_char = self.negative.to_lowercase().chars().next().unwrap_or('n');
232247
let submit_keys = format!("{affirmative_char}/{negative_char}/enter");
233248
help_keys.push((&submit_keys, "submit"));

0 commit comments

Comments
 (0)