Tin

Examples · cli · 50 of 339

hello

args() and exit(code): a command-line program.

examples/cli/hello.tintin run examples/cli/hello.tin
// args() and exit(code): a command-line program.
//   tin run examples/cli/hello.tin Ada Grace
fn main() {
  let names = args()                       // the words after the file name
  if names.len == 0 {
    print("usage: tin run hello.tin <name>...")
    exit(2)                                // stop here, with exit status 2
  }
  for n in names {
    print("hello, {n}")
  }
}