def auto2
cswap-bend-cli@0.1.0.0 · switch.bend:182
import cswap-bend-cli@0.1.0.0/switch.bend as Switch
import Base
import cswap-bend-cli@0.1.0.0/json.bend as Json
import cswap-bend-cli@0.1.0.0/act.bend as Act
import cswap-bend-cli@0.1.0.0/swbase.bend as B
import cswap-bend-cli@0.1.0.0/swlive.bend as L
import cswap-bend-cli@0.1.0.0/store/base.bend as SBase
182def auto2(+strategy: String, +ctx: SBase.Ctx, +seq: Json.Json, +l: L.Live, +cur: Maybe<&2, String>, +label: String, +models: List<&2, String>, +opts: L.Opts) -> Act.of(Json.Json):
183 match cur:
184 case None{}:
185 Act.pure(Json.Json, B.noop(label, "unmanaged-account", "Active account is not managed; run cswap --add-account", B.ref(None{}, L.lv_email(l)), []))
186 case Some{c}:
187 Act.cond(Json.Json, Nat.is_lt(List.length(&2, String, B.slots_of(seq)), 2n),
188 Act.pure(Json.Json, B.noop(label, "only-one-account", "Only one account is managed. Add more accounts to switch between.", B.ref(Some{c}, L.lv_email(l)), [])),
189 auto3(strategy, ctx, seq, c, L.lv_email(l), label, models, opts))