each Keyword in Oil - oils-for-unix/oils GitHub Wiki

Idea:

cat tasks.tsv2 | each (...) {
  run-task $name $age
}


# extract 2 of 4 columns, assert that there are 4
cat tasks.tsv2 | each (_, name Str, age Int, _) {
  run-task $name $age
}

Idea for ad-hoc data with no schema. This is useful because argv aren't typed!!!

tasks() {
  # note no header line:
  echo $'one\t000'
  echo $'two\t555'
}

tasks | each [name age] { run-task $name $age }
  • how do you specify parallelism?
cat tasks.tsv2 | each -parallel 4 (...) {
  echo $name $age
}

Is that hard to parse?

Other options

each --verbose or each --ui -- show progress! Enable cancellation?

Links

Oil Builtins

Instead of:

tasks() {
  echo $'name\tage:int'
  echo $'one\t000'
  echo $'two x\t555'
}

In Oil you could write:

proc tasks {
  tsv2-row    name    age:int
  tsv2-row    one     000
  tsv2-row    'two x' 555
}

It's just a nicer syntax.