You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-15Lines changed: 21 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,28 @@
4
4
[](https://docs.rs/rexpect)
5
5
[](http://philippkeller.github.io/rexpect)
6
6
7
-
8
-
Spawn, control, and respond to expected patterns of child applications and processes, enabling the automation of interactions and testing. Components include:
9
-
-**session**: start a new process and interact with it; primary module of rexpect.
10
-
-**reader**: non-blocking reader, which supports waiting for strings, regex, and EOF.
7
+
Spawn, control, and respond to expected patterns of child applications and
8
+
processes, enabling the automation of interactions and testing. Components
9
+
include:
10
+
11
+
-**session**: start a new process and interact with it; primary module of
12
+
rexpect.
13
+
-**reader**: non-blocking reader, which supports waiting for strings, regex,
14
+
and EOF.
11
15
-**process**: spawn a process in a pty.
12
16
13
-
The goal is to offer a similar set of functionality as [pexpect](https://pexpect.readthedocs.io/en/stable/overview.html).
17
+
The goal is to offer a similar set of functionality as
I have created rexpect as a project to learn rust and linux. But now due to some reasons I haven't used Rust in the past 2 years, so I can't keep up with the latest features/crate dependencies
22
+
I have created rexpect as a project to learn rust and linux. But now due to some
23
+
reasons I haven't used Rust in the past 2 years, so I can't keep up with the
24
+
latest features/crate dependencies
18
25
19
-
It has become hard now to judge pull requests. If you would be willing to either take over this repo entirely or join in as a maintainer to help evaluate PR please contact me.
26
+
It has become hard now to judge pull requests. If you would be willing to either
27
+
take over this repo entirely or join in as a maintainer to help evaluate PR
28
+
please contact me.
20
29
21
30
## Examples
22
31
@@ -55,24 +64,21 @@ fn do_ftp() -> Result<()> {
55
64
Ok(())
56
65
}
57
66
58
-
59
67
fnmain() {
60
68
do_ftp().unwrap_or_else(|e|panic!("ftp job failed with {}", e));
61
69
}
62
70
```
63
71
64
72
### Example with bash and reading from programs
65
73
66
-
67
74
```rust
68
75
externcrate rexpect;
69
76
userexpect::spawn_bash;
70
77
userexpect::errors::*;
71
78
72
-
73
79
fndo_bash() ->Result<()> {
74
80
letmutp=spawn_bash(Some(2000))?;
75
-
81
+
76
82
// case 1: wait until program is done
77
83
p.send_line("hostname")?;
78
84
lethostname=p.read_line()?;
@@ -102,7 +108,6 @@ fn do_bash() -> Result<()> {
102
108
fnmain() {
103
109
do_bash().unwrap_or_else(|e|panic!("bash job failed with {}", e));
104
110
}
105
-
106
111
```
107
112
108
113
### Example with bash and job control
@@ -122,7 +127,6 @@ extern crate rexpect;
122
127
userexpect::spawn_bash;
123
128
userexpect::errors::*;
124
129
125
-
126
130
fndo_bash_jobcontrol() ->Result<()> {
127
131
letmutp=spawn_bash(Some(1000))?;
128
132
p.execute("ping 8.8.8.8", "bytes of data")?;
@@ -157,7 +161,9 @@ rust stable, beta and nightly on both Linux or Mac.
157
161
## Design decisions
158
162
159
163
- use error handling of [error-chain](https://github.com/brson/error-chain)
160
-
- use [nix](https://github.com/nix-rust/nix) (and avoid libc wherever possible) to keep the code safe and clean
161
-
- sadly, `expect` is used in rust too prominently to unwrap `Option`s and `Result`s, use `exp_*` instead
164
+
- use [nix](https://github.com/nix-rust/nix) (and avoid libc wherever possible)
165
+
to keep the code safe and clean
166
+
- sadly, `expect` is used in rust too prominently to unwrap `Option`s and
0 commit comments