Current status: early proof of concept
Usage: mock-ssh-server <starlark script>
This will spin up an SSH server on port 2222 that runs the specified Starlark script whenever anyone connects.
Starlark is a Python-like language used by Bazel for configuration.
mock-ssh-server
currently exposes four built-in functions to the script:
Name | Description |
---|---|
writeline(string) | Send text and a newline to the connected client |
write(string) | Send text to the connected client |
readline(string) | Read a whole line from the client |
matchline(string: regexp) | Keep reading a line until the input matches a pattern, return the match and any capturing groups |
Simple example:
writeline("What is your name?")
name = readline()
writeline("Hello " + name + "!")
Try it out with:
go get -u github.com/simon-engledew/mock-ssh-server
mock-ssh-server examples/helloworld.star