- Rust 50.9%
- Lua 49.1%
| .woodpecker | Add release to CI | |
| rockspecs | Version 0.3.0 | |
| src | Remove regex as a default feature | |
| types | Add options parameter | |
| .envrc | Add Luarocks | |
| .gitignore | Add Luarocks | |
| Cargo.lock | Update rexpect | |
| Cargo.toml | Update rexpect | |
| lexpect-dev-1.rockspec | Adjust build flags | |
| LICENSE | Add license | |
| readme.md | Remove regex as a default feature | |
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 readstrip_ansi_escape_codes: bool?- if ansi escape codes should be stripped from the outputpassthrough: 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.