def descendant

cli@0.2.0.0 · cli.bend:5925

import cli@0.2.0.0/cli.bend as Cli
import Base

5925# T2: the first subcommand in pre-order whose args take the long.
5926def descendant(items: List<&2, Item>, +prefix: String, +long: String,
5927    found: Maybe<&2, String>) -> Maybe<&2, String>:
5928  match items found:
5929    case _ Some{path}: Some{path}
5930    case Nil{} None{}: None{}
5931    case Sub{name, about, +children} <> tail None{}:
5932      +path = String.concat([prefix, " ", name])
5933      descendant(tail, prefix, long, descendant(children, path, long,
5934        owned(find_option(children, long), path)))
5935    case head <> tail None{}: descendant(tail, prefix, long, None{})

Uses (7)

Used by (1)