feat!: Add Builder, make timeout std::time::Duration, add configurable poll_frequency, sleep between checks is relative to timeout#165
Conversation
There was a problem hiding this comment.
chore!:
timeoutnow has typestd::time::Duration
This is not a chore but a fix.
| } | ||
|
|
||
| /// See `spawn` | ||
| pub fn spawn_with_options(command: Command, options: Options) -> Result<PtySession, Error> { |
There was a problem hiding this comment.
This commit is a breaking change but isn't marked as such
|
|
||
| /// Process factory, which can be used in order to configure the properties of a command. | ||
| #[derive(Default)] | ||
| pub struct Builder { |
There was a problem hiding this comment.
Normally a builder gets named for what it is building, so PtySessionBuilder
| #[derive(Default)] | ||
| pub struct Builder { | ||
| /// A command to spawn | ||
| pub(super) command: Option<Command>, |
There was a problem hiding this comment.
pub(super) doesn't seem to be needed
| /// Set the command which will be executed | ||
| pub fn command(mut self, command: Command) -> Self { | ||
| self.command = Some(command); | ||
| self |
There was a problem hiding this comment.
This is set in new, why are we allowing it to be overridden?
| } | ||
|
|
||
| /// Set filtering out escape codes, such as colors. | ||
| pub fn strip_ansi_escape_codes(mut self) -> Self { |
| #[derive(Default)] | ||
| pub struct Builder { | ||
| /// A command to spawn | ||
| pub(super) command: Option<Command>, |
There was a problem hiding this comment.
Why allow an Option<Command> instead of a Command?
There was a problem hiding this comment.
Note: this needs a much bigger API re-work than to just add a builder because of the interactions within the different session types.
|
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 |
Thanks a lot, I will have a look and update my PR accordingly |
|
Comment from a lurker... @LightVillet in this PR is it possible to include a method for:
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 |
Closes #142
Closes #144