FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat!: Add `Builder`, make `timeout` `std::time::Duration`, add configurable `poll_frequency`, sleep between checks is relative to `timeout` by LightVillet · Pull Request #165 · rust-cli/rexpect · GitHub

feat!: Add Builder, make timeout std::time::Duration, add configurable poll_frequency, sleep between checks is relative to timeout - #165

Open
LightVillet wants to merge 3 commits into
rust-cli:mainfrom
LightVillet:configurable-timeouts
Open

feat!: Add Builder, make timeout std::time::Duration, add configurable poll_frequency, sleep between checks is relative to timeout#165
LightVillet wants to merge 3 commits into
rust-cli:mainfrom
LightVillet:configurable-timeouts

Conversation

LightVillet commented Mar 14, 2026
edited
Loading

Copy link
Copy Markdown

Closes #142
Closes #144

Comment thread examples/bash.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

chore!: timeout now has type std::time::Duration

This is not a chore but a fix.

Comment thread src/session.rs
}

/// See `spawn`
pub fn spawn_with_options(command: Command, options: Options) -> Result<PtySession, Error> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This commit is a breaking change but isn't marked as such

Comment thread src/session.rs

/// Process factory, which can be used in order to configure the properties of a command.
#[derive(Default)]
pub struct Builder {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Normally a builder gets named for what it is building, so PtySessionBuilder

Comment thread src/session.rs
#[derive(Default)]
pub struct Builder {
/// A command to spawn
pub(super) command: Option<Command>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

pub(super) doesn't seem to be needed

Comment thread src/session.rs
Comment on lines +223 to +226
/// Set the command which will be executed
pub fn command(mut self, command: Command) -> Self {
self.command = Some(command);
self

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is set in new, why are we allowing it to be overridden?

Comment thread src/session.rs
}

/// Set filtering out escape codes, such as colors.
pub fn strip_ansi_escape_codes(mut self) -> Self {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Let's accept a bool

Comment thread src/session.rs
#[derive(Default)]
pub struct Builder {
/// A command to spawn
pub(super) command: Option<Command>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why allow an Option<Command> instead of a Command?

Comment thread src/session.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note: this needs a much bigger API re-work than to just add a builder because of the interactions within the different session types.

epage commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

I've released rexpect 0.7 which should make it easier to evolve the API. The builder changes should not be needed anymore.

For changing timeout_ms to a duration, I'd do it by adding a timeout method and deprecatingtimeout_ms.

LightVillet commented Mar 17, 2026
edited
Loading

Copy link
Copy Markdown
Author

I've released rexpect 0.7 which should make it easier to evolve the API. The builder changes should not be needed anymore.

For changing timeout_ms to a duration, I'd do it by adding a timeout method and deprecatingtimeout_ms.

Thanks a lot, I will have a look and update my PR accordingly

Copy link
Copy Markdown

Comment from a lurker... @LightVillet in this PR is it possible to include a method for:

  • Get the current timeout value on PtySession (i.e. .get_timeout())
  • Set a new timeout on PtySession (i.e. .set_timeout())

Doing this would make it easier to adjust timeouts based on how long you expect a command to run. For instance, an SSH CLI file transfer under Cisco IOS can take minutes (due to slow writes to flash memory), but most other Cisco IOS commands should return within one second.

cc: @epage

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Sleeps between timeout checks should be relative to the size of the timeout Configurable sleeps

3 participants


Back | FazBrowse Home | New Git URL