1 个不稳定版本
0.1.0 | 2022年8月15日 |
---|
#1082 在 开发工具
41KB
915 代码行数
Xsync
一个帮助同步本地和远程服务器上项目的工具,仅推送修改,就像 rsync 一样
-
您可以通过在基础目录中创建一个类似
.gitignore
文件的.xsyncignore
文件来忽略文件和文件夹 -
将文件或目录同步到远程服务器
use std:: path::Path;
use rxsync::{connection::SshCred, sync, connection::AuthOption};
//multiple auth options include
//Attempt basic password authentication.
let auth1= AuthOption::UserauthPassword("ssh_username".to_string(), "ssh_password".to_string());
//authenticate the current connection with the first public key found in an SSH agent
let auth2= AuthOption::UserauthAgent("ssh_username".to_string());
//Attempt public key authentication using a PEM encoded private key file stored on disk
let auth3= AuthOption::UserauthPubkeyFile("ssh_username".to_string(), Some(&Path::new("pub_key")), &Path::new("private_key"), Some("passphrase"));
let conn =SshCred::new(
auth1,
"host".to_string(),
"port".to_string(),
);
sync(&conn, &Path::new("source_path/"), Some(Path::new("dir_path"))).unwrap();
-
这将在基础目录中创建一个
.xsync.toml
文件,该文件是服务器上最新同步的文件和目录的快照。该文件是 xsync 跟踪要更新、删除或上传的文件或文件夹的方式 -
克隆目录或文件
use std:: path::Path;
use rxsync::{connection::SshCred, clone_dir, clone_file, connection::AuthOption};
let auth= AuthOption::UserauthAgent("ssh_username".to_string());
let conn =SshCred::new(
auth,
"host".to_string(),
"port".to_string(),
);
clone_dir(&conn, &Path::new("dir_to_clone"), &Path::new("write_dest")).unwrap();
//config_dest is the destination you wish to write your .xsync.toml file which is optional
clone_file(&conn, &Path::new("file_to_clone"), &Path::new("write_dest"), Some(&Path::new("config_dest"))).unwrap();
依赖项
~5.5MB
~113K SLoC