
InMemory.pudu
Pudu25 lines1.1 KB
1/** @Examples.InMemory.Program — sources, expansion, and defaults without files */2module InMemory34import Std.Bytes as Bytes5import Std.Io as Io6import Std.Map as Map7import PuduLangEnvironment.Domain.Encoding as Encoding8import PuduLangEnvironment.Loader as Loader9import PuduLangEnvironment.Options as Options10import PuduLangEnvironment.Source as Source111213fn main() -> Int {14 let shared = Source.Text("shared", "export REGION=eu-west\nBUCKET=assets-$REGION # where uploads go\n")15 let local = Source.Data("local", Bytes.fromText("CITY='Mal' \nBANNER=\"$\{GREETING:-Hello\} from $BUCKET\"\n"))16 let options = Options.defaults().withSources(&[shared, local]).withExportSyntax().withExpansion().withTrimValues().withEncoding(Encoding.Latin1)17 match Loader.readOver(&options, &Map.empty()) {18 case Ok(values) => {19 for pair in values.entries() { let _shown = Io.writeLine(pair[0] + "=" + pair[1]) }20 if values.get("BANNER") == Some("Hello from assets-eu-west") && values.get("CITY") == Some("Mal") { 0 } else { 1 }21 }22 case Err(_) => 123 }24}25