quick_file_transfer/config/
misc.rs

1use super::util::*;
2
3/// Styling for the `help` terminal output
4pub fn cli_styles() -> Styles {
5    Styles::styled()
6        .header(AnsiColor::Yellow.on_default() | Effects::BOLD)
7        .usage(AnsiColor::Yellow.on_default() | Effects::BOLD)
8        .literal(AnsiColor::Blue.on_default())
9        .placeholder(AnsiColor::Green.on_default())
10}
11
12#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
13pub enum ColorWhen {
14    Always,
15    Auto,
16    Never,
17}
18
19impl std::fmt::Display for ColorWhen {
20    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21        self.to_possible_value()
22            .expect("no values are skipped")
23            .get_name()
24            .fmt(f)
25    }
26}
27
28/// Used to choose IP version for any commands where that is appropriate
29#[derive(Debug, Default, ValueEnum, Clone, Copy)]
30pub enum IpVersion {
31    #[default]
32    V4,
33    V6,
34}
35
36impl fmt::Display for IpVersion {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        match self {
39            IpVersion::V4 => write!(f, "v4"),
40            IpVersion::V6 => write!(f, "v6"),
41        }
42    }
43}
44
45#[derive(Debug, Clone, Copy, ValueEnum)]
46pub enum TransportLayerProtocol {
47    TCP,
48    UDP,
49}
50
51impl fmt::Display for TransportLayerProtocol {
52    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53        match self {
54            TransportLayerProtocol::TCP => write!(f, "tcp"),
55            TransportLayerProtocol::UDP => write!(f, "udp"),
56        }
57    }
58}