Files
mgmt/examples/lang/env0.mcl
James Shubin 046b21b907 lang: Refactor most functions to support modules
This is a giant refactor to move functions into a hierarchial module
layout. While this isn't entirely implemented yet, it should work
correctly once all the import bits have landed. What's broken at the
moment is the template function, which currently doesn't understand the
period separator.
2018-12-20 21:21:30 -05:00

24 lines
570 B
Plaintext

# read and print environment variable
# env TEST=123 EMPTY= ./mgmt run --tmp-prefix --lang=examples/lang/env0.mcl --converged-timeout=5
import "fmt"
import "sys"
$x = sys.getenv("TEST", "321")
print "print1" {
msg => fmt.printf("the value of the environment variable TEST is: %s", $x),
}
$y = sys.getenv("DOESNOTEXIT", "321")
print "print2" {
msg => fmt.printf("environment variable DOESNOTEXIT does not exist, defaulting to: %s", $y),
}
$z = sys.getenv("EMPTY", "456")
print "print3" {
msg => fmt.printf("same goes for epmty variables like EMPTY: %s", $z),
}