mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-06-25 14:22:54 +02:00
cli: add new 'hostname' function
This will enable us to query for the current system's hostname in both Unix and Windows environments. We could have pulled in the 'gethostname' crate for this, but: 1. I'm not a huge fan of micro-crates. 2. The 'gethostname' crate panics if an error occurs. (Which, to be fair, an error should never occur, but it seems plausible on borked systems? ripgrep runs in a lot of places, so I'd rather not take the chance of a panic bringing down ripgrep for an optional convenience feature.) 3. The 'gethostname' crate uses the 'windows-targets' crate from Microsoft. This is arguably the "right" thing to do, but ripgrep doesn't use them yet and they appear high-churn. So I just added a safe wrapper to do this to winapi-util[1] and then inlined the Unix version here. This brings in no extra dependencies and the routine is fallible so that callers can recover from potentially strange failures. [1]: https://github.com/BurntSushi/winapi-util/pull/14
This commit is contained in:
@ -144,6 +144,7 @@ error message is crafted that typically tells the user how to fix the problem.
|
||||
|
||||
mod decompress;
|
||||
mod escape;
|
||||
mod hostname;
|
||||
mod human;
|
||||
mod pattern;
|
||||
mod process;
|
||||
@ -155,6 +156,7 @@ pub use crate::{
|
||||
DecompressionReader, DecompressionReaderBuilder,
|
||||
},
|
||||
escape::{escape, escape_os, unescape, unescape_os},
|
||||
hostname::hostname,
|
||||
human::{parse_human_readable_size, ParseSizeError},
|
||||
pattern::{
|
||||
pattern_from_bytes, pattern_from_os, patterns_from_path,
|
||||
|
Reference in New Issue
Block a user