diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2023-07-02 22:06:56 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2023-07-02 22:06:56 +0000 |
commit | 3710b35f46fa3b4e374797a81186ff9a43410787 (patch) | |
tree | 2ddbe0883399a2670f28cab9c663fecd87a3d185 /src/main.rs | |
parent | Update deps (diff) | |
download | miniserve-3710b35f46fa3b4e374797a81186ff9a43410787.tar.gz miniserve-3710b35f46fa3b4e374797a81186ff9a43410787.zip |
Remove atty dep
We can now use the stabilized IsTerminal trait.
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index bf9d600..47d4303 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::io::{self, Write}; +use std::io::{self, IsTerminal, Write}; use std::net::{IpAddr, SocketAddr, TcpListener}; use std::thread; use std::time::Duration; @@ -110,7 +110,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { // terminal, we should refuse to start for security reasons. This would be the case when // running miniserve as a service but forgetting to set the path. This could be pretty // dangerous if given with an undesired context path (for instance /root or /). - if !atty::is(atty::Stream::Stdout) { + if !io::stdout().is_terminal() { return Err(ContextualError::NoExplicitPathAndNoTerminal); } @@ -232,7 +232,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { ); // print QR code to terminal - if miniserve_config.show_qrcode && atty::is(atty::Stream::Stdout) { + if miniserve_config.show_qrcode && io::stdout().is_terminal() { for url in display_urls .iter() .filter(|url| !url.contains("//127.0.0.1:") && !url.contains("//[::1]:")) @@ -249,7 +249,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { } } - if atty::is(atty::Stream::Stdout) { + if io::stdout().is_terminal() { println!("Quit by pressing CTRL-C"); } |