DEV Community

Cover image for Run README.md in your terminal
Sebastian Tiedtke
Sebastian Tiedtke

Posted on • Edited on

Run README.md in your terminal

Please note: rdme has been renamed to runme available at https://github.com/stateful/runme

Documentation has always been a crucial part of onboarding onto a non-trivial system. For this reason, developers of packaged software started including README files as part of their distribution documentation dating back to the mid-1970s.

Today, the readme is still around but has morphed into a markdown-based README.md file that lives in your repo’s version control. It has become part of modern development culture, and you will find them everywhere.

retro.png

Swordfish90’s Apple2 retro terminal viewing runme’s README.md

Lowering entry barriers for developers

At Stateful, we want to lower development onboarding barriers and make prerequisites, setup, and workflows as approachable as possible. Source code hosting platforms such as GitHub have already elevated the README.md as a repo’s primary entry point in their UX, but they still diverge from code and documentation and we want to see more.

Run README commands straight from my terminal?

Primarily born out of the annoyance of never-ending README copy & paste, our teammate Adam Babik decided to utilize a Markdown Abstract Syntax Tree parser to generate a naive digest of README snippets and make them easily runnable. This is a prototype (take the happy path!), but we are pleased with the initial results. Illustrated here using Husky - a popular solution to manage git hooks:

💡 We skipped $ runme run npm-install for brevity

Running through husky’s example with ease

Running through husky’s example with ease

Let's run through it

The parsing is still far from perfect, but with best-effort pattern-matching of the AST into a data structure of command snippet pairs, we are often able to capture commands and their implied description. The outputted list tries to maintain the order initially defined in the README.md. Feel free to copy & paste the following step-by-step breakdown. You really shouldn’t have to, though, now that you have runme 😎.

Simply list all commands



$ runme list


Enter fullscreen mode Exit fullscreen mode

List all commands in your README

Prepare package.json’s scripts for git-pre-commit hook



$ runme run npm-pkg


Enter fullscreen mode Exit fullscreen mode

Prepare package.json’s scripts for git-pre-commit hook

Now install example pre-commit husky hook



$ runme run npx-husky


Enter fullscreen mode Exit fullscreen mode

 raw `runme run npx-husky` endraw  which will install an example husky hook

Trigger the pre-commit hook



$ runme run git-commit


Enter fullscreen mode Exit fullscreen mode

 raw `runme run git-commit` endraw

Using a simple runme run <name> you can run command blocks (check out the tab completion too) without much fuzz (as illustrated above making a sample commit to trigger the git-pre-commit hook). For a simple CLI tool, we have been pleasantly surprised at how natural the experience feels for interacting with tasks (if you like the terminal). You can find some additional examples inside of runme’s repo.

Maybe in the future we will employ automation to execute the README’s commands continuously and detect outdated docs, but for now let's catch those issues by running them regularly with runme!

Go ahead and take runme for a spin

If you are on MacOS and using homebrew, it’s as easy as installing runme from our tap:



# please note `rdme` has been renamed to `runme`
$ brew install stateful/tap/runme


Enter fullscreen mode Exit fullscreen mode

You can use scoop to install a version of runme on Windows. However, please note that currently only shell environments (PowerShell is not supported yet) are supported.



$ scoop bucket add stateful https://github.com/stateful/scoop-bucket.git && scoop install stateful/runme


Enter fullscreen mode Exit fullscreen mode

For all other platforms, please check out the install section in runme’s README.md.

Much more runme could do

Using runme internally has led to a lengthy list of possible improvements, but we’ve intentionally decided to keep it simple and release runme's codebase as alpha.

Here’s a list of possible improvements:

  • more robust parsing, configurability and/or ML/AI
  • annotating markdown to achieve deterministic snippets
  • introducing interactivity and “color” into CLI experience
  • embedding run controls&output in README markdown viewer
  • automated ENV resolution, injection of user runtime config
  • C/I testability, as in “always know when you are breaking docs”
  • deterministic order of commands, without building Makefile inside of READMEs
  • what else?

Check out runme’s GitHub issues to get a better sense of what projects are on the agenda.

Let us know how it goes

If runme struck the same cord with you or, if you have strong feelings in one way or another, we would love to hear about it. Using the tool you will likely uncover edge cases. Please don't be shy to tell us about them on Discord or just drop a line in the comments below.

Top comments (7)

Collapse
 
sourishkrout profile image
Sebastian Tiedtke

We took rdme/runme a step further: Run your README.md as an interactive notebook. Zero changes required to the underlying markdown. Check it out: dev.to/sourishkrout/run-your-readm...

Collapse
 
tobiobeck profile image
Tobi Obeck

Cool idea! I could see how this is useful for installation commands or the like that aren't npm scripts (which are listed in package.json anyway).
Would be handy if there was an additional VS Code extension that shows the commands with a run button similar to the npm scripts panel in the explorer side bar.

Collapse
 
randellbrianknight profile image
Randell Brian Knight

This is awesome! 🎉Thanks 😎

Collapse
 
bobbyiliev profile image
Bobby Iliev

Very cool!

Collapse
 
thealpha706 profile image
TheAlpha706

🔥🔥

Collapse
 
andrewbaisden profile image
Andrew Baisden

Wow, awesome this is so useful!

Collapse
 
pierre profile image
Pierre-Henry Soria ✨

Amazing article! Thanks for sharing this Sebastian! 🎉