Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a filter would be desirable #41

Closed
fow0ryl opened this issue Feb 24, 2022 · 9 comments
Closed

a filter would be desirable #41

fow0ryl opened this issue Feb 24, 2022 · 9 comments

Comments

@fow0ryl
Copy link

fow0ryl commented Feb 24, 2022

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
Copy link

DerPoet commented Feb 24, 2022

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
Copy link
Owner

Canop commented Feb 24, 2022

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

  • lfs --filter 'type=ext4'
  • lfs --filter 'type=ext4&disk=hdd'
  • lfs --filter 'type=ext4 & (use_percent > 85 | free < 1234567 )'

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
Copy link
Author

fow0ryl commented Feb 24, 2022

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
Copy link
Owner

Canop commented Mar 3, 2022

It works:
image

@Canop
Copy link
Owner

Canop commented Mar 3, 2022

= is less strict than ==:
image

@Canop Canop closed this as completed in e51128a Mar 3, 2022
@Canop
Copy link
Owner

Canop commented Mar 3, 2022

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

Tests & feedback would be appreciated.

@DerPoet
Copy link

DerPoet commented Mar 5, 2022

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
Copy link
Owner

Canop commented Mar 6, 2022

@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
Copy link
Owner

Canop commented Mar 6, 2022

BTW it's released in lfs 2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants