new: add use_cl option and separate to function

This commit is contained in:
qwjyh 2025-03-01 23:44:21 +09:00
parent 851c0259a1
commit cad49e8d50
3 changed files with 21 additions and 3 deletions

View file

@ -69,6 +69,9 @@ pub(crate) enum Commands {
/// Manually specify ssh key
#[arg(long)]
ssh_key: Option<PathBuf>,
/// Use git command.
#[arg(short, long)]
use_cl: bool,
},
/// Check config files validity.

View file

@ -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<String>,
use_sshagent: bool,
ssh_key: Option<PathBuf>,
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<String>,
use_sshagent: bool,
ssh_key: Option<PathBuf>,
) -> Result<()> {
info!("cmd_sync");
let repo = Repository::open(config_dir)?;

View file

@ -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,