use miette::Result;
-pub async fn run(hook_name: &str) -> Result<()> {
+#[derive(Clone, Copy, Debug, clap::ValueEnum)]
+pub enum HookName {
+ PostReceive,
+}
+
+impl std::fmt::Display for HookName {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let name = match self {
+ HookName::PostReceive => "post-receive",
+ };
+ f.write_str(name)
+ }
+}
+
+pub async fn run(hook_name: HookName) -> Result<()> {
tracing::info!(hook = %hook_name, "hook invoked");
Ok(())
}
/// Invoked by git hooks configured via hook.<name>.command.
Hook {
- /// The hook name (e.g. pre-receive, post-receive).
- hook_name: String,
+ /// The hook name (e.g. post-receive).
+ hook_name: crate::commands::hook::HookName,
},
}
match command {
Commands::Serve => commands::serve::run(&config).await?,
Commands::Exec { command } => commands::exec::run(&config, command).await?,
- Commands::Hook { hook_name } => commands::hook::run(&hook_name).await?,
+ Commands::Hook { hook_name } => commands::hook::run(hook_name).await?,
}
Ok(())