@@ -134,10 +134,10 @@ impl<W: Write> StreamSession<W> {
134134 ///
135135 /// ```
136136 /// use rexpect::{spawn, ReadUntil};
137- /// # use rexpect::errors::* ;
137+ /// # use rexpect::error::Error ;
138138 ///
139139 /// # fn main() {
140- /// # || -> Result<()> {
140+ /// # || -> Result<(), Error > {
141141 /// let mut s = spawn("cat", Some(1000))?;
142142 /// s.send_line("hello, polly!")?;
143143 /// s.exp_any(vec![ReadUntil::String("hello".into()),
@@ -155,7 +155,6 @@ impl<W: Write> StreamSession<W> {
155155pub struct PtySession {
156156 pub process : PtyProcess ,
157157 pub stream : StreamSession < File > ,
158- pub commandname : String , // only for debugging purposes now
159158}
160159
161160// make StreamSession's methods available directly
@@ -179,10 +178,10 @@ impl DerefMut for PtySession {
179178/// ```
180179///
181180/// use rexpect::spawn;
182- /// # use rexpect::errors::* ;
181+ /// # use rexpect::error::Error ;
183182///
184183/// # fn main() {
185- /// # || -> Result<()> {
184+ /// # || -> Result<(), Error > {
186185/// let mut s = spawn("cat", Some(1000))?;
187186/// s.send_line("hello, polly!")?;
188187/// let line = s.read_line()?;
@@ -192,19 +191,11 @@ impl DerefMut for PtySession {
192191/// # }
193192/// ```
194193impl PtySession {
195- fn new (
196- process : PtyProcess ,
197- timeout_ms : Option < u64 > ,
198- commandname : String ,
199- ) -> Result < Self , Error > {
194+ fn new ( process : PtyProcess , timeout_ms : Option < u64 > ) -> Result < Self , Error > {
200195 let f = process. get_file_handle ( ) ;
201196 let reader = f. try_clone ( ) ?;
202197 let stream = StreamSession :: new ( reader, f, timeout_ms) ;
203- Ok ( Self {
204- process,
205- stream,
206- commandname,
207- } )
198+ Ok ( Self { process, stream } )
208199 }
209200}
210201
@@ -241,11 +232,10 @@ pub fn spawn(program: &str, timeout_ms: Option<u64>) -> Result<PtySession, Error
241232
242233/// See `spawn`
243234pub fn spawn_command ( command : Command , timeout_ms : Option < u64 > ) -> Result < PtySession , Error > {
244- let commandname = format ! ( "{:?}" , & command) ;
245235 let mut process = PtyProcess :: new ( command) ?;
246236 process. set_kill_timeout ( timeout_ms) ;
247237
248- PtySession :: new ( process, timeout_ms, commandname )
238+ PtySession :: new ( process, timeout_ms)
249239}
250240
251241/// A repl session: e.g. bash or the python shell:
@@ -293,10 +283,10 @@ impl PtyReplSession {
293283 ///
294284 /// ```
295285 /// use rexpect::spawn_bash;
296- /// # use rexpect::errors::* ;
286+ /// # use rexpect::error::Error ;
297287 ///
298288 /// # fn main() {
299- /// # || -> Result<()> {
289+ /// # || -> Result<(), Error > {
300290 /// let mut p = spawn_bash(Some(1000))?;
301291 /// p.execute("cat <(echo ready) -", "ready")?;
302292 /// p.send_line("hans")?;
0 commit comments