From e8a0d63a3254f6dcd9539e32d75cb981731b387e Mon Sep 17 00:00:00 2001 From: Nelson Penn Date: Tue, 20 Aug 2024 00:03:06 -0400 Subject: [PATCH] Use clap for yact binary --- Cargo.toml | 8 +++++++- src/bin/yact.rs | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 79afab5..60067b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "yact" version = "0.1.0" edition = "2021" license = "GPL-3.0-or-later" +description = "Yet another commit transformer: a tool for formatting staged files with minimal disturbance to developer workflow." # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,9 +11,14 @@ license = "GPL-3.0-or-later" lto = true [dependencies] -git2 = {version = "0.19", default-features = false} +clap = { version = "4.5.16", features = ["derive"], optional = true } +git2 = { version = "0.19", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" +[features] +default = ["cli"] +cli = ["clap"] + [dev-dependencies] uuid = { version = "1.10.0", features = ["v4"] } diff --git a/src/bin/yact.rs b/src/bin/yact.rs index 95b5ec1..5613c4c 100644 --- a/src/bin/yact.rs +++ b/src/bin/yact.rs @@ -1,6 +1,20 @@ +use std::path::PathBuf; + +use clap::Parser; use yact::{pre_commit, BuiltinTransformer, ShellCommandTransformer, TransformerOptions}; +#[derive(Parser)] +#[command(version, about)] +pub struct Args { + /* + * TODO: add config file and configuration + * #[arg(short, long, value_name="CONFIG_FILE")] + * config: Option, + */ +} + pub fn main() { + let _cli = Args::parse(); let config = [ ( "**/*.rs",