def switch_auto

cswap-bend-cli@0.1.0.0 · switch.bend:259

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/store.bend as Store
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
import cswap-bend-cli@0.1.0.0/store/io.bend as SIo

259# `cswap switch [--strategy best|next-available] [--model NAMES]`: strategy
260# "" rotates through `sequence`; "next-available" also skips accounts with no
261# headroom; "best" moves to the account with strictly more headroom. Usage is
262# read from cache/usage.json as it stands (no fetch). A logged-out machine
263# activates the active (else first) slot. The result is the object of
264# contract 2.3; no-op outcomes are results, not errors. A live unmanaged login
265# is reported as `unmanaged-account` (the CLI adds it with Store.add_current).
266def switch_auto(+ctx: SBase.Ctx, +strategy: String, +models: List<&2, String>, +opts: L.Opts) -> Act.of(Json.Json):
267  do ActM<Json.Json>:
268    m : Maybe<&2, Json.Json> <- SIo.read_seq(SBase.root_of(ctx))
269    auto1(strategy, ctx, B.sel_s(String.eq(strategy, "best") || String.eq(strategy, "next-available"), strategy, "rotation"), B.sel_ls(String.eq(strategy, "best") || String.eq(strategy, "next-available"), models, []), opts, m)

Uses (16)

Used by (1)