def fault_tips
cli@0.2.0.0 · cli.bend:6012
import cli@0.2.0.0/cli.bend as Cli
import Base
6012
6013def fault_tips(fault: ScanFault, +c: Cmd, +path: List<&2, String>,
6014 argv: List<&2, String>, here: String, +items: List<&2, Item>,
6015 globals: List<&2, Item>) -> List<&2, List<&2, Segment>>:
6016 match fault:
6017 case E01{+token}:
6018 List.concat(&2, List<&2, Segment>, [
6019 long_tips(long_name(token), token, cmd_name(c), path, items,
6020 cmd_items(c), here),
6021 similar("argument", suggest(token, List.concat(&2, String, [
6022 long_candidates(List.append(&2, Item, items, globals)),
6023 ["--help"],
6024 Bool.pick(List<&2, String>, Bool.and(List.is_empty(&2, String, path),
6025 has_version_item(items)), ["--version"], []),
6026 ]))),
6027 dash_tip(String.starts_with(token, "-"), token, items, c, argv),
6028 ])
6029 case E02{+name}: similar("subcommand", suggest(name, sub_candidates(items)))
6030 case E04{+arg, +value, reason}:
6031 similar("value", suggest(value,
6032 display_choices(List.append(&2, Item, items, globals), arg, [])))
6033 case E09{+token}:
6034 dash_tip(String.starts_with(token, "-"), token, items, c, argv)
6035 case _: Nil{}