Shareable CLI demo?

Ben Lovy on September 25, 2019

Hi folks! Over the weekend I was enlisted to produce a proof of concept demo, to pitch as part of a project proposal presentation. Perfect! I di... [Read Full]
markdown guide

If it's reading from stdin and spitting out on stdout...

Option 4

... can't you just hook it up to a route on a web server?

That way people could 'demo' it using curl.

Or you could build a thin web frontend using a smidgen of vanilla JavaScript.


I could if it were just crunching an input and spitting an output, but it runs the user through a series of interactive prompts. I don't think curl is suited for this, could be wrong?


Yup, curl won't cut it.

Are the prompts for 'configuration' only? If so you could still stick it on a server, but take some querystring params for the options (built into a web page UI), then do the major work server side.

Another option... perform the interaction over TCP instead of HTTP - now you can use netcat to demo it.

Another option... perform the interaction over TCP instead of HTTP - now you can use netcat to demo it.

(I like this idea so much I almost want to write a 'framework' for it...)

  • start a TCP listener
  • on connection, start the cli tool in a separate process
  • hook stdin and stdout of the tool to the TCP connection
  • ????

The WASM thing is absolutely overkill, with you there 100%.

Are the prompts for 'configuration' only?

Not really - the prompts are the main event. It builds a branching tree of prompts from the input file provided, and can refer to previously received responses.

The "real" option would be to ditch text prompts and build graphical widgets, which sounds fun, too, but not a one-day thing.

This definitely sounds like it fits. I've never mucked about with TCP before but I don't think there's anything in my way conceptually, at least.

I've just scrapped around with this in Go - I'm sure you can convert to Rust with ease - using cowsay as the target command line app:

package main

import (

func main() {
    listen, err := net.Listen("tcp", "")
    if err != nil {
    conn, err := listen.Accept()
    if err != nil {

    cmd := exec.Command("cowsay")
    cmd.Stdin = conn
    cmd.Stdout = conn


Above and beyond, David, thanks for the sample!

That might be exactly the ticket - no real need to translate to Rust, I might just start with your Go template if you don't mind, that looks like less friction.


Ah jeeze, you may have just completely solved this problem. I didn't realize you could include other files to read!

I think I owe you a beer or something.


Ah, shoot - looks like they don't support external dependencies for Rust, and I'm leaning on a parsing library.


Can you cut and paste the relevant bits into a file? And include that file?

I'll play with it, but I think I need to be able to pull in the parsing crate to the build. It would probably be feasible to implement parsing by hand now that I've figured out the file format, which solves the problem, but not quickly.

Better than rewriting the whole thing in JavaScript, though?


Why don't you have an interactive session this afternoon where you poll the audience and use their prompts? You might be solving a problem you don't have.

And if they want to play with it, buy yourself time after the demo. 1) you have limited time 2) you don't want to disengage them from the presentation


This would be the best solution if I had access to the audience. I'm remote and will not be the one giving the presentation tomorrow.

I think the eventual solution here will be to pont them to download a zip file with a precompiled bundle. Not quite a seamless as a URL, but that's already done and will work in about three clicks.


Why are you giving them access to it anyway? I understand wanting to wow the audience, but at the same time you risk your IP with your idea, no?

No real IP risk. This is an engineering unit pitching a project to their own company.


When I hear "demo" and "low effort" I immediately think of zeit and netlifly. I haven't tried them with Rust, but in many cases you can deploy your code as an endpoint and curl against it with very little effort.


Oh, that's cool! I've heard of these platforms but not used either, will definitely take a look. Thank you!


I looked it up and unfortunately there's no Rust support, so you'll still be doing the WASM two-step if you go this route.

Oh wow, thanks for the research. Good to know.

I think the WASM<->JS app I'm building will work, and I do think I can deliver in a (long) day, but it felt like I was overthinking what sounds like a simple ask.


Maybe Live Share? I keep trying to find excuses to use that...


This is interesting, might fit. Thanks, never heard of this.


You'd have to have your demo users running VS Code though.

True. I know some will, but likely not all. And if I'm requiring them to install something, they may as well just download my precompiled bundle from github.

Looking through this post and replies... If I were you I'd focus on making sure the demo is solid and doesn't break. And record a backup if something fails during the presentation.

What you want to do doesn't seem worth the sweat equity at this time


Whoa, more than fine. Looks like a one-stop solution. Never heard of this, thank you so much.

code of conduct - report abuse