-
Notifications
You must be signed in to change notification settings - Fork 119
Make more use of Read
and Write
#108
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
Comments
@felipesere I just noticed that the |
This PR adds a `retain-for` duration argument to the console. Additionally, I have modified the proto to not include the total_time for tasks,resources and async ops and instead contain `created_at` and `dropped_at` fields. A separate `console-util` crate has been added that contains the logic for parsing a duration string. Close console-rs#108 Signed-off-by: Zahari Dichev <[email protected]> Co-authored-by: Eliza Weisman <[email protected]>
Sorry for the late reply but I would welcome a PR. |
Attempted fix at #123. I couldn't test that easily. @felipesere If you get the chance to do so, your feedback would be very welcome. (Besides, I would be interested in your setup for the TestTerminal crate: I'm interested in testing some changes to the |
@pksunkara Any news on this? This an essential feature in my application. I could continue working on this if you comment on the pr? As far as I can tell these are the lines using stdin:
These ones seems problematic as well: I would check if we have a ReadWritePair and use the reader. Otherwise the functions above. Does that sound right? What about implementing these four functions for the TermTarget Enum: impl TermTarget {
fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
if let TermTarget::ReadWritePair(pair) = self {
todo!()
} else {
io::stdin().read(buf)
}
}
fn read_line(&self, buf: &mut String) -> io::Result<usize> {
if let TermTarget::ReadWritePair(pair) = self {
todo!()
} else {
io::stdin().read_line(buf)
}
}
fn read_secure(&self, buf: &mut &[u8]) -> io::Result<String> {
if let TermTarget::ReadWritePair(pair) = self {
todo!()
} else {
read_secure()
}
}
fn read_single_key(&self, buf: &mut &[u8]) -> io::Result<Key> {
if let TermTarget::ReadWritePair(pair) = self {
todo!()
} else {
read_single_key()
}
}
} Then we do not need to worry about any checking in the Term struct |
I would welcome a PR here. But, I haven't been focusing on maintaining console anymore. So, you will have to wait for mitsuhiko to review |
Creating a Term from
Read
andWrite
was added in #34 (merged #93 ) which is pretty cool 🎉I am using that mechanism to write a
TestTerminal
that buffers calls toWrite
internally and has prepared content forRead
.My code uses
term.read_line()
though, which to my surprise usesstdin()
directly.I was expecting that to go through
Read
.Is that something that could be adjusted? I can probably try and submit a PR?
The text was updated successfully, but these errors were encountered: