def fault_message

cli@0.2.0.0 · cli.bend:5783

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

5783def fault_message(fault: ScanFault, path: String,
5784    items: List<&2, Item>) -> List<&2, Segment>:
5785  match fault:
5786    case E01{token}:
5787      List.concat(&2, Segment, [[plain("unexpected argument ")],
5788        quoted(token, [Yellow{}]), [plain(" found")]])
5789    case E02{name}:
5790      plain("unrecognized subcommand ") <> quoted(name, [Yellow{}])
5791    case E03{arg}:
5792      [plain(String.concat(["a value is required for '", arg,
5793        "' but none was supplied"]))]
5794    case E04{arg, value, reason}:
5795      List.concat(&2, Segment, [[plain("invalid value ")],
5796        quoted(value, [Yellow{}]),
5797        [plain(String.concat([" for '", arg, "': ", reason]))]])
5798    case E05{arg, value}:
5799      List.concat(&2, Segment, [[plain("unexpected value ")],
5800        quoted(value, [Yellow{}]),
5801        [plain(String.concat([" for '", arg,
5802          "' found; no more were expected"]))]])
5803    case E06{missing}:
5804      [plain(String.append(
5805        "the following required arguments were not provided:",
5806        missing_lines(missing)))]
5807    case E07{a, b}:
5808      [plain(String.concat(["the argument '", a, "' cannot be used with '", b,
5809        "'"]))]
5810    case E08{a, b}:
5811      [plain(String.concat(["the argument '", a, "' requires '", b, "'"]))]
5812    case E09{token}:
5813      List.concat(&2, Segment, [[plain("unexpected argument ")],
5814        quoted(token, [Yellow{}]), [plain(" found")]])
5815    case E10{}:
5816      [plain(String.concat(["'", path,
5817        "' requires a subcommand but none was provided\n  [subcommands: ",
5818        String.join(visible_subs(items), ", "), "]"]))]
5819    case E11{arg, value, name, reason}:
5820      List.concat(&2, Segment, [[plain("invalid value ")],
5821        quoted(value, [Yellow{}]),
5822        [plain(String.concat([" for '", arg, "' from environment variable ",
5823          name, ": ", reason]))]])

Uses (14)

Used by (1)