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