1 | #![allow (clippy::single_component_path_imports)] |
2 | |
3 | mod any_value; |
4 | pub(crate) mod flat_map; |
5 | pub(crate) mod flat_set; |
6 | mod graph; |
7 | mod id; |
8 | mod str_to_bool; |
9 | |
10 | pub use self::id::Id; |
11 | |
12 | pub(crate) use self::any_value::AnyValue; |
13 | pub(crate) use self::any_value::AnyValueId; |
14 | pub(crate) use self::flat_map::Entry; |
15 | pub(crate) use self::flat_map::FlatMap; |
16 | pub(crate) use self::flat_set::FlatSet; |
17 | pub(crate) use self::graph::ChildGraph; |
18 | pub(crate) use self::str_to_bool::str_to_bool; |
19 | pub(crate) use self::str_to_bool::FALSE_LITERALS; |
20 | pub(crate) use self::str_to_bool::TRUE_LITERALS; |
21 | |
22 | pub(crate) mod color; |
23 | |
24 | pub(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 |
30 | pub(crate) const USAGE_CODE: i32 = 2; |
31 | |
32 | pub(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" ))] |
42 | pub(crate) fn eq_ignore_case(left: &str, right: &str) -> bool { |
43 | left.eq_ignore_ascii_case(right) |
44 | } |
45 | |
46 | #[cfg (feature = "unicode" )] |
47 | pub(crate) use unicase::eq as eq_ignore_case; |
48 | |