summaryrefslogtreecommitdiffstats
path: root/vendor/clap-3.2.20/src/util/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /vendor/clap-3.2.20/src/util/mod.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap-3.2.20/src/util/mod.rs')
-rw-r--r--vendor/clap-3.2.20/src/util/mod.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/clap-3.2.20/src/util/mod.rs b/vendor/clap-3.2.20/src/util/mod.rs
new file mode 100644
index 000000000..8adc8db17
--- /dev/null
+++ b/vendor/clap-3.2.20/src/util/mod.rs
@@ -0,0 +1,40 @@
+#![allow(clippy::single_component_path_imports)]
+
+mod fnv;
+mod graph;
+mod id;
+mod str_to_bool;
+
+pub use self::fnv::Key;
+
+pub(crate) use self::str_to_bool::str_to_bool;
+pub(crate) use self::str_to_bool::FALSE_LITERALS;
+pub(crate) use self::str_to_bool::TRUE_LITERALS;
+pub(crate) use self::{graph::ChildGraph, id::Id};
+
+pub(crate) mod color;
+
+pub(crate) const SUCCESS_CODE: i32 = 0;
+// While sysexists.h defines EX_USAGE as 64, this doesn't seem to be used much in practice but
+// instead 2 seems to be frequently used.
+// Examples
+// - GNU `ls` returns 2
+// - Python's `argparse` returns 2
+pub(crate) const USAGE_CODE: i32 = 2;
+
+pub(crate) fn safe_exit(code: i32) -> ! {
+ use std::io::Write;
+
+ let _ = std::io::stdout().lock().flush();
+ let _ = std::io::stderr().lock().flush();
+
+ std::process::exit(code)
+}
+
+#[cfg(not(feature = "unicode"))]
+pub(crate) fn eq_ignore_case(left: &str, right: &str) -> bool {
+ left.eq_ignore_ascii_case(right)
+}
+
+#[cfg(feature = "unicode")]
+pub(crate) use unicase::eq as eq_ignore_case;