marionette-commander

A purescript-marionette renderer for interactive CLI programs


License
MIT
Install
psc-package install marionette-commander

Documentation

purescript-marionette-commander

marionette-commander is a marionette renderer for interactive CLI programs.

Documentation

Installation

spago install marionette
spago install marionette-commander

Getting started

In the simplest form a marionette-commander program can look like this:

type State = Int

data Msg = CountUp | CountDown

update :: Msg -> State -> State
update msg state = case msg of
  CountUp -> state + 1
  CountDown -> state - 1

view :: State -> CliSurface Msg
view count = CliSurface
  ( TextOutput $
      "Current count: " <> show count
  )
  ( KeyInput (KeyPrompt "Use up/down keys") case _ of
      { name: "up" } -> Just CountUp
      { name: "down" } -> Just CountDown
      _ -> Nothing
  )

initialState :: State
initialState = 0

It's a counter that runs in the terminal, the user can count up and down by using the arrow keys. Check out the full code in the examples folder.

Examples

PureCounter

Source

spago run --main Test.Examples.PureCounter

CountDown

Source

spago run --main Test.Examples.CountDown

WordTicker

Source

spago run --main Test.Examples.WordTicker

Snake

The snake implementation can be found in this repo.

Inspired By

  • brick A declarative Unix terminal UI library written in Haskell
  • ink React for interactive command-line apps