agentstatedeveloper_cli/commands/
hooks.rs1use anyhow::Result;
6use clap::Args;
7
8use crate::commands::init::{find_project_root, hook_statuses, hooks_path_is_set};
9use crate::config::Config;
10
11#[derive(Debug, Args)]
12pub struct HooksArgs {}
13
14pub fn run(cfg: &Config, _args: HooksArgs) -> Result<()> {
15 let root = find_project_root(&cfg.db_path);
16 let statuses = hook_statuses(&root);
17 let path_set = hooks_path_is_set(&root);
18
19 println!("ASD git hooks (.asd/hooks/):\n");
20
21 for h in &statuses {
22 let indicator = if h.installed { "✓" } else { "✗" };
23 println!(" {} {:<16} trigger: {}", indicator, h.filename, h.trigger);
24 println!(" {:<16} command: {}", "", h.command);
25 println!(" {:<16} purpose: {}", "", h.purpose);
26 println!();
27 }
28
29 let all_installed = statuses.iter().all(|h| h.installed);
30
31 println!(
32 " core.hooksPath: {}",
33 if path_set {
34 ".asd/hooks (active)"
35 } else {
36 "not set (hooks are installed but NOT active)"
37 }
38 );
39
40 if !all_installed || !path_set {
41 println!("\n To install/repair hooks: asd init");
42 }
43
44 Ok(())
45}