tosc-rs / mnemos

An Operating System for Building Small Computers
https://mnemos.dev
Apache License 2.0
260 stars 18 forks source link

CLI command to execute a Forth script over SerMux and return the result #316

Open hawkw opened 7 months ago

hawkw commented 7 months ago

It would be nice to have a CLI tool to run on a dev machine that takes a Forth script from stdin, sends it over sermux to a MnemOS target, and then prints the result of executing the Forth script to stdout. This could be used to facilitate automated on-device testing.

This could probably be really simple to actually implement. Rather than having the CLI command actually own the USB TTY, I would probably expect it to connect to a running Crowtty instance on the host over TCP, so that other stuff like SerMux logging doesn't get interrupted. But, if there's no Crowtty instance running, it could potentially take ownership over the TTY instead?

I'm imagining a UX like this:

$ crowtty exec < '." hello world\n"'
[stderr] Connected to crowtty on 127.0.0.1:1004
hello world
ok.

Making it a subcommand of Crowtty could let us reuse some of the existing arg parsing and stuff.