@@ -13,9 +13,10 @@ use tabled::{settings::Style, Table, Tabled};
13
13
14
14
use crate :: api:: { self , client:: Client } ;
15
15
16
- // Pretty logo :3
16
+ /// ASCII art logo loaded from ascii.txt file
17
17
static ASCII_LOGO : & str = include_str ! ( "ascii.txt" ) ;
18
18
19
+ /// Prints the intro message with styling and warning
19
20
fn print_intro ( ) -> color_eyre:: Result < ( ) > {
20
21
cliclack:: intro ( format ! (
21
22
"{name_disk}{name_saw} {DISK}{SAW} - {version}" ,
@@ -33,6 +34,7 @@ fn print_intro() -> color_eyre::Result<()> {
33
34
Ok ( ( ) )
34
35
}
35
36
37
+ /// Formats a block device for display, showing path, model and size
36
38
fn render_device ( device : & api:: BlockDevice , path_width : usize ) -> String {
37
39
let model = device. model . as_deref ( ) . unwrap_or ( "Unknown" ) ;
38
40
format ! (
@@ -44,6 +46,7 @@ fn render_device(device: &api::BlockDevice, path_width: usize) -> String {
44
46
)
45
47
}
46
48
49
+ /// Struct representing a partition for display purposes
47
50
#[ derive( Debug , Tabled ) ]
48
51
struct DisplayPartition {
49
52
#[ tabled( rename = "💽 Name" ) ]
@@ -73,6 +76,7 @@ impl From<&api::Partition> for DisplayPartition {
73
76
}
74
77
}
75
78
79
+ /// Prints a formatted table of partitions for a given block device
76
80
fn print_partitions ( client : & mut Client , device : & api:: BlockDevice ) -> color_eyre:: Result < ( ) > {
77
81
let mut partitions: Vec < DisplayPartition > =
78
82
device. partitions . iter ( ) . map ( Into :: into) . collect :: < Vec < _ > > ( ) ;
@@ -88,12 +92,14 @@ fn print_partitions(client: &mut Client, device: &api::BlockDevice) -> color_eyr
88
92
Ok ( ( ) )
89
93
}
90
94
95
+ /// Main entry point for the disk partitioning interface
91
96
pub fn run ( ) -> color_eyre:: Result < ( ) > {
92
97
print_intro ( ) ?;
93
98
94
99
let our_exe = std:: env:: current_exe ( ) ?. to_string_lossy ( ) . to_string ( ) ;
95
100
let mut client = Client :: new_privileged_with_path ( & our_exe) ?;
96
101
102
+ // Get list of valid block devices, filtering out loopback devices without backing files
97
103
let mut devices = client
98
104
. get_block_devices ( ) ?
99
105
. into_iter ( )
@@ -120,6 +126,7 @@ pub fn run() -> color_eyre::Result<()> {
120
126
121
127
print_partitions ( & mut client, & device) ?;
122
128
129
+ // Main interaction loop
123
130
loop {
124
131
let p = * cliclack:: select ( "What do you want to do" )
125
132
. items ( & enums_to_cliclack ( & [
0 commit comments