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 | |
parent | Update deps (diff) | |
download | miniserve-3710b35f46fa3b4e374797a81186ff9a43410787.tar.gz miniserve-3710b35f46fa3b4e374797a81186ff9a43410787.zip |
Remove atty dep
We can now use the stabilized IsTerminal trait.
-rw-r--r-- | Cargo.lock | 27 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 8 |
3 files changed, 7 insertions, 29 deletions
@@ -448,17 +448,6 @@ dependencies = [ ] [[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - -[[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1159,15 +1148,6 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" @@ -1354,7 +1334,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "libc", "windows-sys 0.48.0", ] @@ -1371,7 +1351,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "rustix 0.38.2", "windows-sys 0.48.0", ] @@ -1590,7 +1570,6 @@ dependencies = [ "anyhow", "assert_cmd", "assert_fs", - "atty", "bytesize", "chrono", "chrono-humanize", @@ -1690,7 +1669,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "libc", ] @@ -25,7 +25,6 @@ actix-web = { version = "4", features = ["macros", "compress-brotli", "compress- actix-web-httpauth = "0.8" alphanumeric-sort = "1" anyhow = "1" -atty = "0.2" bytesize = "1" chrono = "0.4" chrono-humanize = "0.2" 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"); } |