garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

.. /programs/frits/hello.frits

raw

script / Console

// `frits run hello Anna` greets Anna; with no name, it asks for one.

fn greeting(who: Str) -> Str {
    "Hello, {who}!"
}

on main() {
    let who = match Console.args().get(0) {
        Some(name) => name,
        None => Console.ask("Who shall I greet?"),
    }
    Console.print(greeting(who))
}

test "a greeting names who it greets" {
    assert(greeting("Anna") == "Hello, Anna!", "the name is in it")
}