]> git.proxmox.com Git - cargo.git/blob - vendor/clap/src/util/mod.rs
New upstream version 0.63.1
[cargo.git] / vendor / clap / src / util / mod.rs
1 #![allow(clippy::single_component_path_imports)]
2
3 mod fnv;
4 mod graph;
5 mod id;
6 mod str_to_bool;
7
8 pub use self::fnv::Key;
9
10 pub(crate) use self::str_to_bool::str_to_bool;
11 pub(crate) use self::str_to_bool::FALSE_LITERALS;
12 pub(crate) use self::str_to_bool::TRUE_LITERALS;
13 pub(crate) use self::{graph::ChildGraph, id::Id};
14
15 pub(crate) mod color;
16
17 pub(crate) const SUCCESS_CODE: i32 = 0;
18 // While sysexists.h defines EX_USAGE as 64, this doesn't seem to be used much in practice but
19 // instead 2 seems to be frequently used.
20 // Examples
21 // - GNU `ls` returns 2
22 // - Python's `argparse` returns 2
23 pub(crate) const USAGE_CODE: i32 = 2;
24
25 pub(crate) fn safe_exit(code: i32) -> ! {
26 use std::io::Write;
27
28 let _ = std::io::stdout().lock().flush();
29 let _ = std::io::stderr().lock().flush();
30
31 std::process::exit(code)
32 }
33
34 #[cfg(not(feature = "unicode"))]
35 pub(crate) fn eq_ignore_case(left: &str, right: &str) -> bool {
36 left.eq_ignore_ascii_case(right)
37 }
38
39 #[cfg(feature = "unicode")]
40 pub(crate) use unicase::eq as eq_ignore_case;