From f7dbcc9539de7635ca263e5459d0d3fc76ad1ce7 Mon Sep 17 00:00:00 2001 From: "Christopher L. Crutchfield" Date: Fri, 15 Nov 2024 22:27:42 -0800 Subject: [PATCH] feat: start of command line interface --- Cargo.toml | 2 +- src/main.rs | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6676722..770d65e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] - +clap = "4.5.21" diff --git a/src/main.rs b/src/main.rs index e7a11a9..ee3ceea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,40 @@ +use clap::{Command, Arg}; + +fn cli() -> Command { + Command::new("git-lfs-synology") + .about("This is an implementation of a git lfs custom transfer agent. See https://github.com/git-lfs/git-lfs/blob/main/docs/custom-transfers.md for mor information.") + .allow_external_subcommands(true) + .subcommand( + Command::new("login") + .about("Allows logging into the Synology NAS.") + .args_conflicts_with_subcommands(true) + .flatten_help(true) + .arg( + Arg::new("USER") + .short('u') + .long("user") + .required(true) + .help("The username for the Synology NAS") + ) + .arg( + Arg::new("URL") + .short('l') + .long("url") + .required(true) + .help("The URL for the Synology NAS") + ) + ) +} + fn main() { - println!("Hello, world!"); + let matches = cli().get_matches(); + + match matches.subcommand() { + Some(("login", sub_matches)) => { + println!("{:?}", sub_matches); + + println!("login") + }, + _ => println!("No subcommand") + } }