Canop / dysk

A linux utility to get information on filesystems, like df but better
https://dystroy.org/dysk
MIT License
890 stars 25 forks source link

a filter would be desirable #41

Closed fow0ryl closed 2 years ago

fow0ryl commented 2 years ago

When using lfs on a server you will get a log list of devices. So I would be great to filter output in a "grep" like way.

i.e. find all rows containing "sdb" in any displayed column -f *,"sdb"

or find all rows containing "sdb" only in the devices column. -f devices,"sdb"

DerPoet commented 2 years ago

Or maybe separate options like --type ext4,xfs or --no-type tmpfs or --min-use 90% or --disk lvm,ssd. Or maybe something like --filter 'type=ext4,xfs and disk!=ssd and use>90'

Canop commented 2 years ago

If I do the filtering, it would probably like those examples:

The structure of the code makes that easy enough and I've already the libraries to to this kind of things (for example bet) which I do in other Rust programs.

fow0ryl commented 2 years ago

Great.

I don't care about the syntax. I was only interested in functionality and of course it should preferably be able to be seamlessly integrated into your program code. At least your suggestion offers many more then I need... But surely there are people around who are waiting for ;)

Canop commented 2 years ago

It works: image

Canop commented 2 years ago

= is less strict than ==: image

Canop commented 2 years ago

I'll have to write the relevant web documentation before I release.

Tests & feedback would be appreciated.

DerPoet commented 2 years ago

Works great. Nice: lfs -a show everything including automounter mountpoint, cgroup entries, etc. But lfs -a -f 'use>=0' restricts the output to mounts which have a real size. Also nice: the possibility of matching substrings ("filesystem=sda"). Although, according to common syntaxes elsewhere (e.g. bash or perl), I would prefer to use =~ here. In normal people's understanding, "=" means equality, but "/dev/sda2" is in no way equal to "sda". And also non-programmers would understand "=~" as "similar" or "roughly equal".

And one general thing: I really appreciate how quickly you respond to all the people around here and how things move forward and forward! Thank you! Keep up the good work!

Canop commented 2 years ago

@DerPoet The main constraint I had given myself for column operators was to have the same whatever the column type. Having a ~= operator would mean it would do something for integers or float numbers too. And ~= is also often used for regular expression based checks. This could come in the future so right now I didn't want to use that cartdridge.

Canop commented 2 years ago

BTW it's released in lfs 2.4.0