Created
March 13, 2019 14:20
-
-
Save epequeno/d00f7572a03980b467221f1289cf26e0 to your computer and use it in GitHub Desktop.
take an input (bash script ideally) and output a json string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Elm 0.19.0 | |
import Browser | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Json.Encode exposing (..) | |
main = Browser.sandbox { init = init, view = view, update = update } | |
type alias Model = | |
String | |
init = | |
"""#!/bin/bash | |
set -xe | |
for i in {1..3}; do | |
echo "${i}" | |
done | |
""" | |
type Msg | |
= Stringify String | |
update msg model = | |
case msg of | |
Stringify newModel -> | |
newModel | |
view model = | |
div [] [ div [] [ text "paste script here:" ] | |
, br [] [] | |
, textarea [ cols 100, rows 20, placeholder init, onInput Stringify ] [] | |
, p [] [ text "output:" ] | |
, br [] [] | |
, code [] [ text (toJSONString model)] | |
] | |
toJSONString text = | |
encode 0 (string text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment