Skip to content

Commit 2d32b19

Browse files
committed
ui: Missing docs
Signed-off-by: Ikey Doherty <[email protected]>
1 parent 95afcf4 commit 2d32b19

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ui/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ use tabled::{settings::Style, Table, Tabled};
1313

1414
use crate::api::{self, client::Client};
1515

16-
// Pretty logo :3
16+
/// ASCII art logo loaded from ascii.txt file
1717
static ASCII_LOGO: &str = include_str!("ascii.txt");
1818

19+
/// Prints the intro message with styling and warning
1920
fn print_intro() -> color_eyre::Result<()> {
2021
cliclack::intro(format!(
2122
"{name_disk}{name_saw} {DISK}{SAW} - {version}",
@@ -33,6 +34,7 @@ fn print_intro() -> color_eyre::Result<()> {
3334
Ok(())
3435
}
3536

37+
/// Formats a block device for display, showing path, model and size
3638
fn render_device(device: &api::BlockDevice, path_width: usize) -> String {
3739
let model = device.model.as_deref().unwrap_or("Unknown");
3840
format!(
@@ -44,6 +46,7 @@ fn render_device(device: &api::BlockDevice, path_width: usize) -> String {
4446
)
4547
}
4648

49+
/// Struct representing a partition for display purposes
4750
#[derive(Debug, Tabled)]
4851
struct DisplayPartition {
4952
#[tabled(rename = "💽 Name")]
@@ -73,6 +76,7 @@ impl From<&api::Partition> for DisplayPartition {
7376
}
7477
}
7578

79+
/// Prints a formatted table of partitions for a given block device
7680
fn print_partitions(client: &mut Client, device: &api::BlockDevice) -> color_eyre::Result<()> {
7781
let mut partitions: Vec<DisplayPartition> =
7882
device.partitions.iter().map(Into::into).collect::<Vec<_>>();
@@ -88,12 +92,14 @@ fn print_partitions(client: &mut Client, device: &api::BlockDevice) -> color_eyr
8892
Ok(())
8993
}
9094

95+
/// Main entry point for the disk partitioning interface
9196
pub fn run() -> color_eyre::Result<()> {
9297
print_intro()?;
9398

9499
let our_exe = std::env::current_exe()?.to_string_lossy().to_string();
95100
let mut client = Client::new_privileged_with_path(&our_exe)?;
96101

102+
// Get list of valid block devices, filtering out loopback devices without backing files
97103
let mut devices = client
98104
.get_block_devices()?
99105
.into_iter()
@@ -120,6 +126,7 @@ pub fn run() -> color_eyre::Result<()> {
120126

121127
print_partitions(&mut client, &device)?;
122128

129+
// Main interaction loop
123130
loop {
124131
let p = *cliclack::select("What do you want to do")
125132
.items(&enums_to_cliclack(&[

0 commit comments

Comments
 (0)