Skip to content

Commit d46069e

Browse files
committed
feat: use picker for custom hook type selection
- Replace text input with Select for hook type - Show valid hook names in interactive picker - Prevents typos and improves UX
1 parent 8e6425f commit d46069e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/init.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use inquire::{MultiSelect, Text};
2+
use inquire::{MultiSelect, Select, Text};
33
use std::{collections::HashSet, fs};
44

55
use crate::{attributes, config, git, hooks, ignore, utils::find_repo_root};
@@ -75,12 +75,11 @@ pub fn run() -> Result<()> {
7575

7676
for item in &hook_selections {
7777
if item == "Add custom hook..." {
78-
let valid = hooks::valid_hook_names().join(", ");
79-
let hook_name = Text::new(" Hook name")
80-
.with_help_message(&format!("Valid: {valid}"))
81-
.prompt()?;
78+
let hook_name = Select::new("Hook type", hooks::valid_hook_names().to_vec())
79+
.prompt()
80+
.map_err(|e| anyhow::anyhow!("Hook selection cancelled: {}", e))?;
8281
let command = Text::new(" Command to run").prompt()?;
83-
custom_hooks.push((hook_name, command));
82+
custom_hooks.push((hook_name.to_string(), command));
8483
} else if let Some(idx) = hook_items.iter().position(|i| i == item) {
8584
if idx < builtins.len() {
8685
selected_builtins.push(builtins[idx].name);

0 commit comments

Comments
 (0)