use crate::atsh::{
add, add_remote, download, get, get_all, initialize, login, pprint, remove, try_get, upload,
Remote, CONFIG,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
initialize(Option::<&std::path::Path>::None)?;
initialize(std::env::home_dir().map(|h| h.join(".atsh.d")))?;
let key = CONFIG.get_enc_key()?;
CONFIG.set_enc_key(Some("secret"))?;
unsafe { std::env::set_var("ASKEY", "secret") };
CONFIG.set_enc_key(Option::<&str>::None)?;
add(
"user",
"password",
"ip",
22,
&Some("name"),
&Option::<&str>::None,
)?;
add_remote(&Remote {
index: 0, user: "user".to_string(),
password: "password".to_string(),
ip: "ip".to_string(),
port: 22,
authorized: false,
name: Some("name".to_string()),
note: Option::<String>::None,
})?;
let remotes = get_all()?;
let remote = remotes.get(0).unwrap();
login(remote.index, false)?;
login(remote.index, true)?;
let find = get(remote.index)?;
let find = try_get(remote.index)?;
remove(&vec![remote.index])?;
download(
remote.index,
&vec!["/path/to/remote/test.txt", "/path/to/host/test.txt"],
)?;
upload(
remote.index,
&vec!["/path/to/local/test.txt", "/path/to/remote/test.txt"],
)?;
pprint(false)?;
pprint(true)?;
CONFIG.create_sshkey(
Option::<&str>::None,
Option::<&std::path::Path>::None,
true)?;
Ok(())
}