mirror of
https://github.com/qwjyh/xdbm
synced 2025-04-18 18:55:51 +09:00
new: add use_cl option and separate to function
This commit is contained in:
parent
851c0259a1
commit
cad49e8d50
3 changed files with 21 additions and 3 deletions
|
@ -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.
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue