1
0
Fork
You've already forked lexpect
0
Light wrapper around rexpect.
  • Rust 50.9%
  • Lua 49.1%
Kate the Gay 6e241ee5b1
Some checks failed
ci/woodpecker/push/ci/1 Pipeline failed
ci/woodpecker/push/ci/3 Pipeline failed
ci/woodpecker/push/ci/2 Pipeline failed
ci/woodpecker/push/ci/4 Pipeline failed
Add release to CI
2025年08月22日 21:44:42 -07:00
.woodpecker Add release to CI 2025年08月22日 21:44:42 -07:00
rockspecs Version 0.3.0 2024年11月12日 21:27:11 -08:00
src Remove regex as a default feature 2024年11月12日 21:26:03 -08:00
types Add options parameter 2024年09月12日 18:50:24 -07:00
.envrc Add Luarocks 2024年09月08日 22:08:06 -07:00
.gitignore Add Luarocks 2024年09月08日 22:08:06 -07:00
Cargo.lock Update rexpect 2025年08月22日 17:29:09 -07:00
Cargo.toml Update rexpect 2025年08月22日 17:29:09 -07:00
lexpect-dev-1.rockspec Adjust build flags 2024年11月12日 14:42:55 -08:00
LICENSE Add license 2024年09月08日 22:01:35 -07:00
readme.md Remove regex as a default feature 2024年11月12日 21:26:03 -08:00

Lexpect

Light wrapper around rexpect.

Installation

$ cargo install lexpect --git https://codeberg.org/KanakoTheGay/lexpect.git [--features lua5x]

Command line

$ lexpect <script>

Methods

Options

  • timeout_ms: integer? - maximum time of waiting in a read
  • strip_ansi_escape_codes: bool? - if ansi escape codes should be stripped from the output
  • passthrough: bool? - if the subprocess should also print to standard out

lexpect.spawn(cmd: string, opt: Options?): Session

Spawns a Session with the given command, this command is passed to sh via sh -c "<cmd>".

lexpect.spawn_args(exec: string, args: string[], opt: Options?): Session

Spawns a Session with a given executable and arguments (passed as an array of strings).

Session:exp_char(needle: string)

Wait until provided char is written out by the child process.

Session:exp_eof()

Wait until EOF is seen (i.e. child process has terminated).

Session:exp_regex(regex: string): string

Note

This function only exists when lexpect was compiled with the regex feature.

Wait until provided regex is matched by the child process output. Returns the matched regex.

Session:exp_string(needle: string)

Wait until provided string is written out by the child process.

Session:flush()

Flushes all unwritten bytes to the child process.

Session:try_read(): string

Returns the character ready to be read if available, else returns nil. This is non-blocking.

Session:read_line(): string

Read one line and return line without the newline. This is blocking.

Session:send(s: string)

Send string to process. It is recommended to call Session:flush() afterwards.

Session:send_control(c: string)

Send a control code to the child process.

Session:send_line(line: string)

Sends the line and a newline to the child process. This flushes the input stream.