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
add regex match plugin #770
Conversation
We've done a bit of brainstorming with how to do a full-featured string match. I think a plugin for regex could work as a stop-gap until we have a full design in place. |
src/plugins/match.rs
Outdated
_ => { | ||
return Err(ShellError::string(format!( | ||
"Unrecognized type in params: {:?}", | ||
args[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean args[1] here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got catch!
@rnxpyke Thanks! |
* Release notes for `0.76` Please add your important new features and breaking changes to the release notes by committing to/opening a PR against the `release-notes-0.76` branch. Thank you! * Add breaking change for plugin signature (nushell#775) * add breaking change * Update blog/2023-02-21-nushell_0_76.md --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com> * add some info on debugging commands * release notes for nushell#7952 (nushell#777) * release notes for nushell#7952 * Fix html tags that broke CI * more debug notes * Add `profile` note and screenshot (nushell#778) * add ast to debug commands section * add breaking change (nushell#790) * Remove example stuff Don't let the lorem ipsum loose * added more breaking changes notes * trim down error message documentation in blog post * Add description of some commands * Do some polishing. sequence multiplication * Screenshot help of a plugin * Add section on nu plugin * Add section on background work and full log * Executive summary * Details to "mul" --------- Co-authored-by: WindSoilder <WindSoilder@outlook.com> Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> Co-authored-by: Bob Hyman <bob.hyman@gmail.com> Co-authored-by: Jakub Žádník <kubouch@gmail.com> Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
This is a simple plugin that filters a table with a regular expression. It requires two arguments. The column of the string that should match and the regex itself.
Example usage:
Return all hidden files in current directory:
ls | match name "^\."
The implenetation fails when it encounters a row where no column/string pair is present. Alternatively it could drop the row silently.
Advantages:
Disadvantages
regex
cratePersonally I think regex matching should be a full fletched command. That way it could interact with all the other thinks that are already possible or will be possible in the future. (easy negation, boolean and, boolean or etc.), but this is a quick and easy solution that would cover the basic usecases for now.