Skip to main content

tree/
tree.rs

1use antex::{Color, ColorMode, StyledText, leaf, node};
2
3fn main() {
4  // Collect the command-line arguments.
5  let args = std::env::args().collect::<Vec<String>>();
6
7  // The first argument may be the color mode, like: auto, never, always
8  let color_mode = if args.len() > 1 { ColorMode::new(&args[1]) } else { ColorMode::default() };
9
10  // The second argument should be the indentation, the tree will be shifted to the right.
11  let indent = if args.len() > 2 { args[2].parse::<usize>().unwrap_or_default() } else { 0 };
12
13  // Build the tree.
14  let root = node(Color::Rgb((80, 12, 140)), color_mode)
15    .line()
16    .bold()
17    .underline()
18    .blue()
19    .s("Quantum AI Core")
20    .end()
21    .child(
22      node(Color::Yellow, color_mode)
23        .line()
24        .yellow()
25        .s("Neural Processing Unit Alpha")
26        .end()
27        .child(
28          leaf(color_mode)
29            .line()
30            .s("Synapse Array Load: 98%")
31            .end()
32            .line()
33            .s("Memory Cache Temp: -12°C")
34            .end()
35            .line()
36            .magenta()
37            .s("Quantum Bit Flux: 0.0012")
38            .end()
39            .line()
40            .bg_yellow()
41            .color(Color::Rgb((10, 10, 10)))
42            .s(" Neural Spike Rate: 14,000 Hz ")
43            .end()
44            .end(),
45        )
46        .child(leaf(color_mode).line().s("Optimization Status: ").green().bold().s("Perfect").end().end())
47        .end(),
48    )
49    .child(
50      node(Color::None, color_mode)
51        .line()
52        .bold()
53        .blue()
54        .s("Dark Matter Storage Array")
55        .end()
56        .child(leaf(color_mode).line().s("Energy Stabilizer: Online").end().end())
57        .child(
58          leaf(color_mode)
59            .line()
60            .s("Matter Density: 9.8×10^-27 kg/m³")
61            .end()
62            .line()
63            .s("Containment Field: 99.99%")
64            .end()
65            .line()
66            .bold()
67            .red()
68            .s("Particle Flux: 1.2×10^6 s^-1")
69            .end()
70            .line()
71            .s("Storage Efficiency: 87%")
72            .end()
73            .end(),
74        )
75        .child(leaf(color_mode).line().s("Backup Node: ").green().bold().underline().s("Ready").end().end())
76        .end(),
77    )
78    .child(
79      node(Color::None, color_mode)
80        .line()
81        .bold()
82        .blue()
83        .s("Interstellar Communication Hub")
84        .end()
85        .child(
86          node(Color::Yellow, color_mode)
87            .line()
88            .yellow()
89            .s("Subspace Transmitter Delta")
90            .end()
91            .child(
92              leaf(color_mode)
93                .line()
94                .s("Signal Strength: 999.9 TW")
95                .end()
96                .line()
97                .cyan()
98                .s("Latency: 0.00042 s")
99                .end()
100                .line()
101                .s("Encryption Protocol: Quantum-256")
102                .end()
103                .line()
104                .s("Active Channels: 42")
105                .end()
106                .end(),
107            )
108            .child(leaf(color_mode).line().s("Maintenance Mode: ").italic().bg_magenta().s("Idle").end().end())
109            .end(),
110        )
111        .child(
112          leaf(color_mode)
113            .line()
114            .cyan()
115            .s("Cosmic Bandwidth Allocation: 12.7 PB/s")
116            .end()
117            .line()
118            .s("Error Correction Status: Optimal")
119            .end()
120            .line()
121            .s("Packet Loss: 0.0001%")
122            .end()
123            .line()
124            .s("Routing Algorithm: Self-Adaptive AI")
125            .end()
126            .end(),
127        )
128        .child(leaf(color_mode).line().s("Hub Status: ").green().italic().bold().s("Fully Operational").end().end())
129        .end(),
130    )
131    .end();
132
133  // Print the tree with indentation.
134  print!("{:1$}", root, indent);
135}