Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

Commit

Permalink
Add auto name fill
Browse files Browse the repository at this point in the history
  • Loading branch information
ayham-1 committed Jan 18, 2020
1 parent 5d0b6cb commit 828b621
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 7 additions & 3 deletions src/lib/ftp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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", "");
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit 828b621

Please sign in to comment.