def scan_short_go
cli@0.2.0.0 · cli.bend:3362
import cli@0.2.0.0/cli.bend as Cli
import Base
3362def scan_short_go(chars: String, +state: ScanState,
3363 found: Maybe<&2, OptFound>) -> Mode:
3364 match chars found:
3365 case SNil{} _:
3366 scan_settle(state)
3367 case SCon{Chr{104}, +tail} None{}:
3368 Closed{Stopped{scan_event(state, HelpHit{False{}})}}
3369 case SCon{Chr{86}, tail} None{}:
3370 scan_short_version(scope_version(scan_state_scope(state)), state)
3371 case SCon{head, tail} None{}:
3372 scan_settle(scan_error(state,
3373 E01{String.append("-", Char.show(head))}))
3374 case SCon{head, tail} Some{OptFound{arg, polarity}}:
3375 match arg:
3376 case ArgInfo{id, usage, short, long, kind, attrs}:
3377 match kind:
3378 case FlagKind{}:
3379 +next = scan_event(state, FlagHit{id, polarity})
3380 scan_short_go(tail, next,
3381 find_short_for_head(tail, scan_state_keys(next)))
3382 case CountKind{}:
3383 +next = scan_event(state, CountHit{id})
3384 scan_short_go(tail, next,
3385 find_short_for_head(tail, scan_state_keys(next)))
3386 case NegatableKind{}:
3387 +next = scan_event(state, FlagHit{id, polarity})
3388 scan_short_go(tail, next,
3389 find_short_for_head(tail, scan_state_keys(next)))
3390 case OptionKind{many}:
3391 scan_short_value(tail, state,
3392 ArgInfo{id, usage, short, long, OptionKind{many}, attrs})
3393 case BareOptionKind{}:
3394 scan_short_bare_value(tail, state,
3395 ArgInfo{id, usage, short, long, BareOptionKind{}, attrs})
3396 case PosKind{required, many}:
3397 scan_settle(state)