summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-10-16 21:27:06 +0200
committerCanop <cano.petrole@gmail.com>2021-10-16 21:27:06 +0200
commit660c6820344e4d28eb20fccd097e3bcd363a768c (patch)
tree93f042f391626987bb1d6f764b23ddf4ca9d5f15
parent98dab67c9b1bfb394152a5633190f46153b1b562 (diff)
add labelsv1.2.0
Fix #15
-rw-r--r--CHANGELOG.md5
-rw-r--r--Cargo.lock14
-rw-r--r--Cargo.toml12
-rw-r--r--README.md17
-rw-r--r--doc/labels.pngbin0 -> 48990 bytes
-rw-r--r--src/args.rs4
-rw-r--r--src/fmt_mount.rs49
-rw-r--r--src/main.rs2
8 files changed, 71 insertions, 32 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9618356..78dcd04 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+<a name="v1.2.0"></a>
+### v1.2.0 - 2021/10/16
+- filesystem labels added to JSON when found
+- `-l` launch argument adds a "label" column to the table
+
<a name="v1.1.0"></a>
### v1.1.0 - 2021/10/08
--units launch argument, to choose between SI units or the old binary ones - Fix #17
diff --git a/Cargo.lock b/Cargo.lock
index a49467d..ec6778b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -128,9 +128,9 @@ dependencies = [
[[package]]
name = "crossterm"
-version = "0.20.0"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0ebde6a9dd5e331cd6c6f48253254d117642c31653baa475e394657c59c1f7d"
+checksum = "486d44227f71a1ef39554c0dc47e44b9f4139927c75043312690c3f476d1d788"
dependencies = [
"bitflags",
"crossterm_winapi",
@@ -212,7 +212,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lfs"
-version = "1.2.0-dev"
+version = "1.2.0"
dependencies = [
"argh",
"crossterm",
@@ -276,9 +276,9 @@ dependencies = [
[[package]]
name = "minimad"
-version = "0.8.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8957f240ecb82a4e699bcf4db189fe8a7f5aa68b9e6d5abf829c62a9ee4630ed"
+checksum = "cd37b2e65fbd459544194d8f52ed84027e031684335a062c708774c09d172b0b"
dependencies = [
"once_cell",
]
@@ -467,9 +467,9 @@ dependencies = [
[[package]]
name = "termimad"
-version = "0.14.3"
+version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d1ea6e542eaec310898d8ba84e5dbda91e95b27e5e023722f0140ca57d72136e"
+checksum = "d06b905c5f505c6fe06d2c1df359d4919c44aed53cb12ff9babf8d5085885a36"
dependencies = [
"crossbeam",
"crossterm",
diff --git a/Cargo.toml b/Cargo.toml
index e3fad25..4cbdb33 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "lfs"
-version = "1.2.0-dev"
+version = "1.2.0"
authors = ["dystroy <denys.seguret@gmail.com>"]
edition = "2018"
keywords = ["linux", "filesystem", "fs"]
@@ -12,15 +12,15 @@ readme = "README.md"
[dependencies]
argh = "0.1.4"
-crossterm = "0.20.0"
+crossterm = "0.21.0"
file-size = "1.0.3"
lfs-core = "0.5.0"
-minimad = "0.8.0"
+minimad = "0.9.0"
serde ="1.0"
serde_json = "1.0"
-termimad = "0.14.0"
+termimad = "0.16.3"
[patch.crates-io]
-#minimad = { path = "../minimad" }
-#termimad = { path = "../termimad" }
+# minimad = { path = "../minimad" }
+# termimad = { path = "../termimad" }
#lfs-core = { path = "../lfs-core" }
diff --git a/README.md b/README.md
index 41ff829..e015e52 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,9 @@ pacman -S lfs
```
lfs
```
+
+### All filesystems
+
By default, **lfs** only shows mount points backed by normal block devices, which are usually the "storage" filesystems you're interested into.
To show them all, use
@@ -65,13 +68,27 @@ To show them all, use
lfs -a
```
+### JSON
+
To get the output as JSON, do `lfs -j` or `lfs -a -j`.
+### Find the filesystem you're interested into
+
You may pass a path to have only the relevant device shown.
For example:
![lfs dot](doc/lfs-dot.png)
+### Show labels
+
+Labels aren't frequently defined, or useful, so they're not displayed by default.
+
+Use `--labels` or `-l` to display them in the table:
+
+![labels](doc/labels.png)
+
+### Other options
+
Use `lfs --help` to list the other arguments.
## Internals
diff --git a/doc/labels.png b/doc/labels.png
new file mode 100644
index 0000000..5f66f2c
--- /dev/null
+++ b/doc/labels.png
Binary files differ
diff --git a/src/args.rs b/src/args.rs
index f5a2670..f2ecbac 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -21,6 +21,10 @@ pub struct Args {
#[argh(switch, short = 'a')]
pub all: bool,
+ /// whether to show labels in the table
+ #[argh(switch, short = 'l')]
+ pub labels: bool,
+
/// output as JSON
#[argh(switch, short = 'j')]
pub json: bool,
diff --git a/src/fmt_mount.rs b/src/fmt_mount.rs
index d6bca98..37e93de 100644
--- a/src/fmt_mount.rs
+++ b/src/fmt_mount.rs
@@ -1,8 +1,8 @@
use {
- crate::units::Units,
+ crate::*,
crossterm::style::Color::*,
lfs_core::*,
- minimad::{OwningTemplateExpander, TextTemplate},
+ minimad::{*, Alignment::*},
termimad::{CompoundStyle, MadSkin, ProgressBar},
};
@@ -15,29 +15,24 @@ static SIZE_COLOR: u8 = 172;
static BAR_WIDTH: usize = 5;
-static MD: &str = r#"
-|-:|:-:|:-:|:-:|:-:|-:|:-:|:-:|:-|:-
-|id|dev|filesystem|disk|type|used|use%|free|size|mount point
-|-:|:-|:-|:-:|:-:|-:|-:|-:|:-
-${mount-points
-|${id}|${dev-major}:${dev-minor}|${fs}|${disk}|${fs-type}|~~${used}~~|~~${use-percents}~~ `${bar}`|*${available}*|**${size}**|${mount-point}
-}
-|-:
-"#;
+pub fn print(mounts: &[Mount], color: bool, args: &Args) {
-pub fn print(mounts: &[Mount], color: bool, units: Units) {
+ let units = args.units;
let mut expander = OwningTemplateExpander::new();
expander.set_default("");
for mount in mounts {
let sub = expander
- .sub("mount-points")
+ .sub("rows")
.set("id", mount.info.id)
.set("dev-major", mount.info.dev.major)
.set("dev-minor", mount.info.dev.minor)
- .set("fs", &mount.info.fs)
+ .set("filesystem", &mount.info.fs)
.set("disk", mount.disk.as_ref().map_or("", |d| d.disk_type()))
- .set("fs-type", &mount.info.fs_type)
+ .set("type", &mount.info.fs_type)
.set("mount-point", mount.info.mount_point.to_string_lossy());
+ if let Some(label) = &mount.fs_label {
+ sub.set("label", label);
+ }
if let Some(stats) = mount.stats.as_ref().filter(|s| s.size() > 0) {
let use_share = stats.use_share();
let pb = ProgressBar::new(use_share as f32, BAR_WIDTH);
@@ -45,7 +40,7 @@ pub fn print(mounts: &[Mount], color: bool, units: Units) {
.set("used", units.fmt(stats.used()))
.set("use-percents", format!("{:.0}%", 100.0 * use_share))
.set("bar", format!("{:<width$}", pb, width = BAR_WIDTH))
- .set("available", units.fmt(stats.available()));
+ .set("free", units.fmt(stats.available()));
}
}
let skin = if color {
@@ -53,8 +48,26 @@ pub fn print(mounts: &[Mount], color: bool, units: Units) {
} else {
MadSkin::no_style()
};
- let template = TextTemplate::from(MD);
- skin.print_owning_expander(&expander, &template);
+
+ let mut tbl = TableBuilder::default();
+ tbl
+ .col(Col::simple("id").align(Right))
+ .col(Col::new("dev", "${dev-major}:${dev-minor}"))
+ .col(Col::simple("filesystem"));
+ if args.labels {
+ tbl.col(Col::simple("label"));
+ }
+ tbl
+ .col(Col::simple("disk").align_content(Center))
+ .col(Col::simple("type"))
+ .col(Col::new("used", "~~${used}~~"))
+ .col(Col::new("use%", "~~${use-percents}~~ `${bar}`").align_content(Right))
+ .col(Col::new("free", "*${free}*").align(Right))
+ .col(Col::new("size", "**${size}**"))
+ .col(Col::simple("mount point").align(Left));
+
+
+ skin.print_owning_expander_md(&expander, &tbl);
}
fn make_colored_skin() -> MadSkin {
diff --git a/src/main.rs b/src/main.rs
index 3420c13..6c405d0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -44,7 +44,7 @@ fn main() -> lfs_core::Result<()> {
mounts.sort_by_key(|m| Reverse(m.size()));
let color = args.color.value()
.unwrap_or_else(|| std::io::stdout().is_tty());
- fmt_mount::print(&mounts, color, args.units);
+ fmt_mount::print(&mounts, color, &args);
}
Ok(())
}