Skip to content

Commit

Permalink
fixes windows build, adds examples for @steveatinfincia additions
Browse files Browse the repository at this point in the history
  • Loading branch information
conradkleinespel committed Mar 27, 2017
1 parent 7399b41 commit e179ad9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "rpassword"
version = "0.3.1"
version = "0.4.0"
authors = ["Conrad Kleinespel <conradk@conradk.com>"]
description = "Read passwords in console applications."
license = "Apache-2.0"
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add `rpassword` as a dependency in Cargo.toml:

```toml
[dependencies]
rpassword = "0.3"
rpassword = "0.4"
```

Import the `rpassword` crate and use the `promt_password_stdout()` to show a message on `stdout` and read a password into a `String`:
Expand All @@ -43,6 +43,17 @@ fn main() {
}
```

Finally, you can read strings with a single line, and without the terminating
newline that `read_line` would add:
```rust
extern crate rpassword;

fn main() {
let response = rpassword::read_response().unwrap();
println!("Your response is {}", response);
}
```

Check [examples/example.rs](examples/example.rs) for a few more examples.

## Contributors
Expand All @@ -55,3 +66,4 @@ Check [examples/example.rs](examples/example.rs) for a few more examples.
* [@petevine](https://github.com/petevine)
* [@psych0d0g](https://github.com/psych0d0g)
* [@retep998](https://github.com/retep998)
* [@steveatinfincia](https://github.com/steveatinfincia)
13 changes: 11 additions & 2 deletions examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ fn main() {
let pass = rpassword::read_password().unwrap();
println!("Your password is {}", pass);

let pass = rpassword::prompt_password_stdout("Password: ").unwrap();
let pass = rpassword::prompt_password_stdout("Password with prompt on stdout: ").unwrap();
println!("Your password is {}", pass);

let pass = rpassword::prompt_password_stderr("Password: ").unwrap();
let pass = rpassword::prompt_password_stderr("Password with prompt on stderr: ").unwrap();
println!("Your password is {}", pass);

let response = rpassword::read_response().unwrap();
println!("Your response is {}", response);

let response = rpassword::prompt_response_stdout("Response with prompt on stdout: ").unwrap();
println!("Your response is {}", response);

let response = rpassword::prompt_response_stderr("Response with prompt on stderr: ").unwrap();
println!("Your response is {}", response);
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod windows {
}
let new_mode_flags = match hide {
true => winapi::ENABLE_LINE_INPUT | winapi::ENABLE_PROCESSED_INPUT,
false => winapi::ENABLE_LINE_INPUT | winapi::ENABLE_PROCESSED_INPUT| ENABLE_ECHO_INPUT,
false => winapi::ENABLE_LINE_INPUT | winapi::ENABLE_PROCESSED_INPUT | winapi::ENABLE_ECHO_INPUT,
};

// We want to be able to read line by line, and we still want backspace to work
Expand Down

0 comments on commit e179ad9

Please sign in to comment.