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

add regex match plugin #770

Merged
merged 4 commits into from Oct 3, 2019
Merged

add regex match plugin #770

merged 4 commits into from Oct 3, 2019

Conversation

rnxpyke
Copy link
Contributor

@rnxpyke rnxpyke commented Oct 2, 2019

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:

  • Few code changes
  • Regex matching

Disadvantages

  • Additional dependency on the regex crate
  • Can only match on Primitive Strings
  • Can't match on nested tables
  • Copies the data because of the Plugin ipc

Personally 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.

@sophiajt
Copy link
Member

sophiajt commented Oct 2, 2019

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.

_ => {
return Err(ShellError::string(format!(
"Unrecognized type in params: {:?}",
args[0]
Copy link

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got catch!

@andrasio andrasio merged commit 7492131 into nushell:master Oct 3, 2019
@andrasio
Copy link
Member

andrasio commented Oct 3, 2019

@rnxpyke Thanks!

bobhy added a commit to bobhy/nushell that referenced this pull request Oct 22, 2023
* 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>
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

Successfully merging this pull request may close these issues.

None yet

4 participants