mirror of
https://github.com/qwjyh/xdbm
synced 2025-04-20 11:45:50 +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
|
/// Manually specify ssh key
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
ssh_key: Option<PathBuf>,
|
ssh_key: Option<PathBuf>,
|
||||||
|
/// Use git command.
|
||||||
|
#[arg(short, long)]
|
||||||
|
use_cl: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Check config files validity.
|
/// Check config files validity.
|
||||||
|
|
|
@ -3,14 +3,28 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{Context, Result, anyhow};
|
||||||
use git2::{build::CheckoutBuilder, Cred, FetchOptions, PushOptions, RemoteCallbacks, Repository};
|
use git2::{Cred, FetchOptions, PushOptions, RemoteCallbacks, Repository, build::CheckoutBuilder};
|
||||||
|
|
||||||
pub(crate) fn cmd_sync(
|
pub(crate) fn cmd_sync(
|
||||||
config_dir: &PathBuf,
|
config_dir: &PathBuf,
|
||||||
remote_name: Option<String>,
|
remote_name: Option<String>,
|
||||||
use_sshagent: bool,
|
use_sshagent: bool,
|
||||||
ssh_key: Option<PathBuf>,
|
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<()> {
|
) -> Result<()> {
|
||||||
info!("cmd_sync");
|
info!("cmd_sync");
|
||||||
let repo = Repository::open(config_dir)?;
|
let repo = Repository::open(config_dir)?;
|
||||||
|
|
|
@ -96,7 +96,8 @@ fn main() -> Result<()> {
|
||||||
remote_name,
|
remote_name,
|
||||||
use_sshagent,
|
use_sshagent,
|
||||||
ssh_key,
|
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 {
|
Commands::Status {
|
||||||
path,
|
path,
|
||||||
storage,
|
storage,
|
||||||
|
|
Loading…
Add table
Reference in a new issue