Various minor changes extracted from unfinished projects #182
1 changed files with 19 additions and 2 deletions
|
@ -36,6 +36,18 @@ enum OutputFormat {
|
||||||
Text,
|
Text,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn format_byte_size(size: usize) -> String {
|
||||||
|
if size < 1024 {
|
||||||
|
format!("{} Bytes", size)
|
||||||
|
} else if size < 1024 * 1024 {
|
||||||
|
format!("{} kB", size / 1024)
|
||||||
|
} else if size < 1024 * 1024 * 1024 {
|
||||||
|
format!("{} MB", size / (1024 * 1024))
|
||||||
|
} else {
|
||||||
|
format!("{} GB", size / (1024 * 1024 * 1024))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(ctx))]
|
#[tracing::instrument(skip(ctx))]
|
||||||
async fn print_bundle_contents<P>(ctx: &sdk::Context, path: P, fmt: OutputFormat) -> Result<()>
|
async fn print_bundle_contents<P>(ctx: &sdk::Context, path: P, fmt: OutputFormat) -> Result<()>
|
||||||
where
|
where
|
||||||
|
@ -50,7 +62,11 @@ where
|
||||||
|
|
||||||
match fmt {
|
match fmt {
|
||||||
OutputFormat::Text => {
|
OutputFormat::Text => {
|
||||||
println!("Bundle: {}", bundle.name().display());
|
println!(
|
||||||
|
"Bundle: {} ({:016x})",
|
||||||
|
bundle.name().display(),
|
||||||
|
bundle.name()
|
||||||
|
);
|
||||||
|
|
||||||
for f in bundle.files().iter() {
|
for f in bundle.files().iter() {
|
||||||
if f.variants().len() != 1 {
|
if f.variants().len() != 1 {
|
||||||
|
@ -63,9 +79,10 @@ where
|
||||||
|
|
||||||
let v = &f.variants()[0];
|
let v = &f.variants()[0];
|
||||||
println!(
|
println!(
|
||||||
"\t{}.{}: {} bytes",
|
"\t{}.{}: {} ({})",
|
||||||
f.base_name().display(),
|
f.base_name().display(),
|
||||||
f.file_type().ext_name(),
|
f.file_type().ext_name(),
|
||||||
|
format_byte_size(v.size()),
|
||||||
v.size()
|
v.size()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue