marionette-commander
is a marionette
renderer for interactive CLI programs.
Documentation
- Module documentation is published on Pursuit.
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
spago run --main Test.Examples.PureCounter
CountDown
spago run --main Test.Examples.CountDown
WordTicker
spago run --main Test.Examples.WordTicker
Snake
The snake implementation can be found in this repo.