From cad49e8d50935d8a3bbb78088acb0f158736a92f Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 1 Mar 2025 23:44:21 +0900 Subject: [PATCH] new: add use_cl option and separate to function --- src/cmd_args.rs | 3 +++ src/cmd_sync.rs | 18 ++++++++++++++++-- src/main.rs | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/cmd_args.rs b/src/cmd_args.rs index 1c3eb3c..32f495b 100644 --- a/src/cmd_args.rs +++ b/src/cmd_args.rs @@ -69,6 +69,9 @@ pub(crate) enum Commands { /// Manually specify ssh key #[arg(long)] ssh_key: Option, + /// Use git command. + #[arg(short, long)] + use_cl: bool, }, /// Check config files validity. diff --git a/src/cmd_sync.rs b/src/cmd_sync.rs index 9611c7a..83b9e23 100644 --- a/src/cmd_sync.rs +++ b/src/cmd_sync.rs @@ -3,14 +3,28 @@ use std::{ path::{Path, PathBuf}, }; -use anyhow::{anyhow, Context, Result}; -use git2::{build::CheckoutBuilder, Cred, FetchOptions, PushOptions, RemoteCallbacks, Repository}; +use anyhow::{Context, Result, anyhow}; +use git2::{Cred, FetchOptions, PushOptions, RemoteCallbacks, Repository, build::CheckoutBuilder}; pub(crate) fn cmd_sync( config_dir: &PathBuf, remote_name: Option, use_sshagent: bool, ssh_key: Option, + use_cl: bool, +) -> Result<()> { + if use_cl { + todo!("do here next") + } else { + cmd_sync_custom(config_dir, remote_name, use_sshagent, ssh_key) + } +} + +fn cmd_sync_custom( + config_dir: &PathBuf, + remote_name: Option, + use_sshagent: bool, + ssh_key: Option, ) -> Result<()> { info!("cmd_sync"); let repo = Repository::open(config_dir)?; diff --git a/src/main.rs b/src/main.rs index 41aab33..0f70238 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,7 +96,8 @@ fn main() -> Result<()> { remote_name, use_sshagent, ssh_key, - } => cmd_sync::cmd_sync(&config_dir, remote_name, use_sshagent, ssh_key)?, + use_cl, + } => cmd_sync::cmd_sync(&config_dir, remote_name, use_sshagent, ssh_key, use_cl)?, Commands::Status { path, storage,