-
Notifications
You must be signed in to change notification settings - Fork 24
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
[apps/cli] Support reading from stdin #249 #250
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for working on this, @LuoZijun!
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @LuoZijun)
apps/cli/src/bin/unic-echo.rs, line 151 at r1 (raw file):
let done_clone = done.clone(); let handler = thread::spawn(move ||{
Could you elaborate on why using a separate thread to read from stdin here?
AFAIU, we should be able to do the same thing with non-blocking IO without spawning a thread. Or, if we want to go with blocking IO, still going with direct read in the main thread seems to be reasonable for such a small CLI tool.
What do you think?
If we support accepting parameters from the basic input, Of course, if everyone thinks this is not going to bother the user, Use case:
|
Oh, I think I see what you mean. I think blocking reading from stdin should only happen if we explicitly want to read from One common condition for reading from stdin is when there are no (non-optional) arguments passed to the CLI. (Like unix's Another common option is when the argument is one HYPHEN-MINUS ( If none of them applies (there's at least one argument passed to the CLI and none of the is So, all of these cases would result in "Hello world" string to be echoed/inspected:
What do you think? |
I think that's great. BTW: Actually is |
@behnam ping ? |
Resolve #249
This change is