-
-
Notifications
You must be signed in to change notification settings - Fork 66
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 ability to take glob patterns from stdin #114
Conversation
as requested in issue solidiquis#51 This adds a new (hidden) flag `--stdin` to indicate that `et` should take input from stdin. Since the naming convention is to use `-` for this, we replace the args `-` with `--stdin` before we hand them over to Clap. Example usage: ```shell $ touch hello.rs helLo.rs HELlo.rs $ fd -e rs '^hel[lL]o' | et - erdtree 0 B ├─ hello.rs 0 B └─ helLo.rs ```
Looks like we've got some failed tests. Additionally for this sort of thing I think it would be nice if we can have users pipe the things to To allow for this sort of thing we'll need to check if |
Fixed the test. I can implement the |
I wasn't aware of that crate. Agreed, |
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.
Let me know if there's anything you disagree with :]
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.
Overall this looks fantastic, thank you for implementing this! My last request will be to remove the usage of -
as per my other comment. Once that's done I'll get this merged in and include it in this Sunday's minor release :]
I restarted the test, but it looks like it is stuck again. |
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.
Okay so after doing some digging and playing around I've learned that Github Actions doesn't provide a tty
so !stdin().is_terminal()
evals to true
which causes stdin
to hang waiting for input. The solution is quite simple, we just need to modify tests/utils/mod.rs
to be this:
let output = cmd
.stdin(Stdio::null()) // add this here
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap()
.wait_with_output()
.unwrap();
Could you make that change and run tests again? Excited to get this merged in!
* remove (hidden) flag `--stdin` * remove ability to detect stdin with "-" * refactor move stdin detection to Context::init
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.
Woot we are good! Thanks for doing this! 💪
as requested in issue #51
This detects input on
stdin
using theis_terminal
crate.Each input line is treated as a separate glob pattern.
This adds a new (hidden) flag--stdin
to indicate thatet
shouldtake input from stdin. Since the naming convention is to use
-
forthis, we replace the args
-
with--stdin
before we hand them overto Clap.
Example usage: