1
0
Fork 0
mirror of https://git.sr.ht/~nixgoat/vento synced 2024-11-21 14:23:05 +00:00

Compare commits

...

5 commits

Author SHA1 Message Date
Lux Aliaga 6c51a8da6e
inv: Show new message if inventory is empty
Basically so it looks less dumb if there aren't any items in the
inventory the user asked to list.
2022-09-17 22:53:44 -03:00
Lux Aliaga 445b5b1671
inv: Add directory count to inventory list
This commit modifies the spacing before an item in the inventory list.
2022-09-17 22:43:34 -03:00
Lux Aliaga 6c10953e88
inv: Add file size to inventory list
This commit also improves formatting in the inventory list.
2022-09-17 18:33:40 -03:00
Lux Aliaga 28bed7faff
vento: Added Anyhow as a dependency
For better error handling. (thank you @j0 for the suggestion)
2022-09-17 17:43:24 -03:00
Lux Aliaga 30f99bbda4
inv: Add file types to inventory list
This will be specially useful once we can access directories from vento
list. For now it still serves the function of letting the user know some
basic metadata about the files they're keeping in their inventory
2022-09-17 17:27:33 -03:00
3 changed files with 157 additions and 22 deletions

103
Cargo.lock generated
View file

@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "anyhow"
version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
[[package]]
name = "atty"
version = "0.2.14"
@ -13,6 +19,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -62,6 +74,15 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
[[package]]
name = "generic-array"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
dependencies = [
"typenum",
]
[[package]]
name = "getrandom"
version = "0.2.7"
@ -94,6 +115,70 @@ version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]]
name = "num"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36"
dependencies = [
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"autocfg",
]
[[package]]
name = "proc-macro2"
version = "1.0.43"
@ -132,6 +217,16 @@ dependencies = [
"thiserror",
]
[[package]]
name = "size_format"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed5f6ab2122c6dec69dca18c72fa4590a27e581ad20d44960fe74c032a0b23b"
dependencies = [
"generic-array",
"num",
]
[[package]]
name = "syn"
version = "1.0.99"
@ -163,6 +258,12 @@ dependencies = [
"syn",
]
[[package]]
name = "typenum"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-ident"
version = "1.0.3"
@ -173,9 +274,11 @@ checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
name = "vento"
version = "0.2.0"
dependencies = [
"anyhow",
"colored",
"dirs",
"fs_extra",
"size_format",
]
[[package]]

View file

@ -9,3 +9,5 @@ edition = "2021"
dirs = "4.0.0"
colored = "2.0.0"
fs_extra = "1.2.0"
anyhow = "1.0.65"
size_format = "1.0.2"

View file

@ -19,6 +19,7 @@
use super::common;
use colored::Colorize;
use size_format::SizeFormatterBinary;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::{fs, process};
@ -57,29 +58,58 @@ pub fn list(slot: &str) {
};
if slotdir.is_dir() {
// Checks if inventory selected exists
println!(
"🗃️ {}",
format!(
"Files in {} inventory:",
match slot {
"active" => format!("{}", slot).bold(),
"inactive" | _ => format!("{}", slot).blue().bold(),
}
)
.green()
);
for file in fs::read_dir(&slotdir).unwrap() {
if fs::read_dir(&slotdir).unwrap().count() == 0 {
println!(
" - {}",
file.unwrap()
.path()
.file_name()
.unwrap()
.to_os_string()
.into_string()
.unwrap()
"🗃️ {}",
format!(
"No files in {}.",
match slot {
"active" => format!("{}", slot).bold(),
"inactive" | _ => format!("{}", slot).blue().bold(),
}
)
.green()
);
} else {
// Checks if inventory selected exists
println!(
"🗃️ {}",
format!(
"Files in {} inventory ({}):",
match slot {
"active" => format!("{}", slot).bold(),
"inactive" | _ => format!("{}", slot).blue().bold(),
},
format!("{}", fs::read_dir(&slotdir).unwrap().count())
.white()
.bold()
)
.green()
);
for file in fs::read_dir(&slotdir).unwrap() {
let file = file.unwrap().path();
println!(
" - [{}] {} ({})",
if file.clone().is_dir() {
format!("D").blue()
} else if file.clone().is_symlink() {
format!("S").yellow()
} else {
format!("F").green()
},
file.clone()
.file_name()
.unwrap()
.to_os_string()
.into_string()
.unwrap(),
format!(
"{}B",
SizeFormatterBinary::new(file.clone().metadata().unwrap().len())
)
);
}
}
} else {
println!(
@ -125,6 +155,6 @@ fn create_slots() {
println!(
"🎉 {}",
format!("Vento has been succesfully initialized!").green()
format!("Vento has been succesfully initialized!").green()
);
}