diff --git a/src/cli.rs b/src/cli.rs index 0ecde76..2f0ebc7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -21,8 +21,6 @@ pub struct CliOptions { pub subcommand: Option } - - #[derive(Debug)] #[derive(StructOpt)] #[derive(Clone)] diff --git a/src/config.rs b/src/config.rs index 30e1107..96caa45 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,10 +1,7 @@ - use serde::{Deserialize, Serialize}; use std::fs; use std::path::PathBuf; use crate::cli::RemoteConfigRecord; -// use std::error::Error; -// use ssh_config::SSHConfig; use crate::cli::CliOptions; @@ -29,7 +26,6 @@ impl Config { } } - impl RemoteConfigRecord { fn host_string(&self) -> String { let mut s: String = String::new(); @@ -48,10 +44,8 @@ pub struct SessionConfig { pub local_root: String, pub remote: RemoteConfigRecord, pub ignore_gitignore: bool, - } - impl SessionConfig { pub fn host_port_string(&self) -> String { diff --git a/src/init.rs b/src/init.rs index 292d01e..3960ad5 100644 --- a/src/init.rs +++ b/src/init.rs @@ -16,18 +16,11 @@ fn create_dirsync_dirs() -> Result<(), std::io::Error> { } pub fn init_dirsync_dir(remote_options: RemoteConfigRecord) -> Result<(), InitError> { - create_dirsync_dirs().map_err(|err| InitError::Io(err))?; - let _ignore_file = File::create("./.dirsync/ignore").map_err(|err| InitError::Io(err))?; let mut config_file = File::create("./.dirsync/config.json").map_err(|err| InitError::Io(err))?; - let config = Config::new(remote_options); - let json = serde_json::to_string_pretty(&config).map_err(|err| InitError::Serde(err))?; - config_file.write_all(json.as_bytes()).map_err(|err| InitError::Io(err))?; - - Ok(()) } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 005441b..ad02428 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,6 @@ fn filter(event: DebouncedEvent) -> Option { fn start_main_loop(config: &SessionConfig) { - println!("config: {:?}", config); rsync(&config); @@ -122,7 +121,6 @@ fn start_main_loop(config: &SessionConfig) { fn main() { - let opts = CliOptions::from_args(); match opts.subcommand { diff --git a/src/remote.rs b/src/remote.rs index f98f96a..5a17f8b 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -3,33 +3,10 @@ use std::io::prelude::*; use std::net::TcpStream; use std::path::PathBuf; - use ssh2::Session; use ssh2::ExtendedData; use crate::config::SessionConfig; -// pub fn echo() { - -// let tcp = TcpStream::connect("pc:22").unwrap(); -// let mut sess = Session::new().unwrap(); -// sess.set_tcp_stream(tcp); -// sess.handshake().unwrap(); - -// // Try to authenticate with the first identity in the agent. -// sess.userauth_agent("skohan").unwrap(); - -// // Make sure we succeeded -// assert!(sess.authenticated()); - -// let mut channel = sess.channel_session().unwrap(); -// channel.exec("ls").unwrap(); -// let mut s = String::new(); -// channel.read_to_string(&mut s).unwrap(); -// println!("{}", s); -// channel.wait_close(); -// println!("{}", channel.exit_status().unwrap()); - -// } pub struct Remote { session: ssh2::Session, @@ -40,7 +17,6 @@ impl Remote { // todo: this shouold take configuration arguemnts pub fn connect(config: &SessionConfig) -> Remote { - let tcp = TcpStream::connect( &config.host_port_string().as_str() ).unwrap(); @@ -61,11 +37,9 @@ impl Remote { session: sess, root: root } - } fn exec(&mut self, command: &str) -> String { - let path = self.root.clone(); let path_str = path.to_str().unwrap(); let cmd = &format!("cd {} && {}", &path_str, &command); @@ -124,7 +98,6 @@ impl Remote { let command2 = &format!("{}", &path_str); self.exec_stream(&command2); - } } \ No newline at end of file