Convert Dict String String to envfile format and back.
Note: This parser follows the simple rules laid out in Docker's guide to its use of envfiles.
A Parser to read an envfile as a Dict String String.
import Parser
import Dict
Parser.run parser <| String.join "\n"
[ "hello=world"
, "# this is a comment"
, ""
, ""
, "_abc=def\\nghi"
]
--> Ok (Dict.fromList [ ("_abc", "def\nghi") , ("hello", "world") ])
Take a
Dict String String, ignore the keys that bash wouldn’t interpret as a variable name and encode the rest as variable declarations, one on each line.