Skip to content

LISP on Python

Nicolas Couture edited this page Apr 19, 2026 · 1 revision

The Hy DSL

MockSSH includes a Domain Specific Language (DSL) built on Hy (a LISP dialect that compiles to Python bytecode). This allows you to define mock servers in a declarative style that resembles a configuration file rather than a script.

LISP on Python

Because Hy is fully integrated with Python, the DSL has direct access to the entire MockSSH library while providing a cleaner syntax for nested command definitions.

Key Macros

mock-ssh

The top-level macro used to launch a server.

(mock-ssh :users {"admin" "1234"}
          :host "127.0.0.1"
          :port 2222
          :prompt "hostname>"
          :commands [...])

command

Defines a standard ArgumentValidatingCommand.

(command :name "wr"
         :type "write"
         :on-success ["write" "[OK]"]
         :on-failure ["write" "Usage: wr m"])

prompting-command

Defines a PromptingCommand flow.

(prompting-command :name "enable"
                   :output "Password: "
                   :required-input "secret"
                   :on-success ["prompt" "admin#"]
                   :on-failure ["write" "Denied."])

Clone this wiki locally