diff --git a/Cargo.toml b/Cargo.toml index 288c17e..c1fa503 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ log = "0.4.8" simple_logger = "1.4.0" ifaces = "0.1.0" dirs = "2.0.2" +whoami = "0.7.0" diff --git a/src/lib/ftp_client.rs b/src/lib/ftp_client.rs index 987352c..8b6f09e 100644 --- a/src/lib/ftp_client.rs +++ b/src/lib/ftp_client.rs @@ -45,12 +45,16 @@ pub mod ftp_client { // Start recieving. ftp::print_reply(&_stream)?; + // Get username for authentication name suggestion. + let username = whoami::username(); + let mut name: String = "".to_string(); let mut pass: String = "".to_string(); - - print!("Name: "); + + print!("Name ({}): ", username); io::stdout().flush()?; io::stdin().read_line(&mut name)?; + if name == "" {name = username;} ftp::send_client_reply(&mut _stream, "USER", &(name.replace("\n", "")))?; ftp::print_reply(&_stream)?; @@ -67,7 +71,7 @@ pub mod ftp_client { if server_info.is_closing { break; } let mut received = "".to_string(); - print!("> "); + print!("{} > ", name); io::stdout().flush()?; io::stdin().read_line(&mut received)?; received = received.replace("\n", ""); diff --git a/src/main.rs b/src/main.rs index 893f43d..3a8b6cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ extern crate log; extern crate simple_logger; extern crate ifaces; extern crate dirs; +extern crate whoami; mod lib; use crate::lib::*;