conradkleinespel / rpassword

Cross platform Rust library to read a password in the terminal (Linux, BSD, OSX, Windows, WASM).
Apache License 2.0
244 stars 38 forks source link

Windows support #1

Closed conradkleinespel closed 9 years ago

conradkleinespel commented 9 years ago

At the moment, rpassword only builds on UNIX. We need Windows support, as seen in https://github.com/rust-lang/cargo/issues/1306.

Making termios work on Windows seems weird to me because I think the name termios refers to a POSIX API. Or maybe that would require a name change, to adhere to the "Rust-way" of not giving cross-platform libraries platform-specific names.

If there's a simple way to add Windows support to rpassword, we could also using #[cfg(...)]. What do you think?

bombless commented 9 years ago

How about switching to another dependency? Here's the situation so far:

I personally think it may be good idea for termios to build for unsupported platforms and leave empty library there for these platforms, as rust-cocoa do similar thing.

conradkleinespel commented 9 years ago

@bombless I don't mind switching to another dependency. If Rustbox supports Windows and we can read passwords without showing them to the screen, that'd be fine by me.

I don't understand what you mean about "termios to build for unsupported platforms". How would that fix the problem ? I'm genuinely curious.

bombless commented 9 years ago

@conradkleinespel If the project contain dependency that fails to build, then cargo build will always fail, so we should opt-out termios for Windows. Cargo.toml only allow opt-in dependencies, so we cannot do that. If dependencies build without problem (and crate termios will export nothing on Windows), we can handle everything at source code level.

I'd admit that there's another solution that we add different dependencies for each platform on Cargo.toml, but it may cause problem, e.g. we may support FreeBSD soon, then you need to edit Cargo.toml to build on it. If we just handle platform-specific thing on source level, it won't have such problem, since we just take Windows as special case, it will automatically build on every UNIX-like system.

conradkleinespel commented 9 years ago

@bombless Ah, OK. I understand now. This is probably a good thing indeed.