switch.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/switch.bend as Switch
12 imports
import Base import ./json.bend as Json import ./act.bend as Act import ./store.bend as Store import ./swbase.bend as B import ./swpick.bend as P import ./swlive.bend as L import ./swrun.bend as R import ./store/base.bend as SBase import ./store/io.bend as SIo import ./store/ops.bend as SOps import ./store/seq.bend as SSeq
Definitions
def ActM source · line 18 · raw
@-A:Type -> Type
def ActM.pure source · line 21 · raw
@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)
def ActM.bind source · line 24 · raw
@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)
def direct4 source · line 27 · raw
@+already:Bool -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+n:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+email:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def direct3 source · line 36 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+n:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+rec:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def direct2 source · line 45 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+ident:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+r:0x0717344745a30ebad1f19045228e8f18/store/seq.Resolved -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def direct1 source · line 54 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+ident:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def switch_to source · line 67 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+ident:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
cswap switch <num|email|alias> [--force]: the result object of contract 2.3.
Already on the target is a no-op (already-active) unless force, which
rewrites the live login from the stored backup (activated). After a real
switch the live login is re-read once, opts later (see verify_live).
def is_disabled source · line 72 · raw
@+rec:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> Bool
def cand_of2 source · line 79 · raw
@+slot:String -> @+rec:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> @+c:String -> @+cfg:Maybe<&2, String> -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/swpick.Cand
def cand_of source · line 82 · raw
@+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> @+slot:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/swpick.Cand)
def cands_of source · line 88 · raw
@+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> @+slots:List<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand>)
def drop_slot_str source · line 98 · raw
@+x:String -> @+xs:List<&2, String> -> List<&2, String>
def usable source · line 105 · raw
@+cs:List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand>
def limits_label source · line 112 · raw
@+models:List<&2, String> -> String
def stay_msg source · line 115 · raw
@+cur:String -> String
def note_pick source · line 118 · raw
@+note:String -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def note_result source · line 125 · raw
@+note:String -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def best_out source · line 128 · raw
@o:0x0717344745a30ebad1f19045228e8f18/swpick.BestOut -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @fallthrough:0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json) -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def best_pick source · line 137 · raw
@+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+models:List<&2, String> -> @+others:List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand> -> 0x0717344745a30ebad1f19045228e8f18/swpick.BestOut
def best_run source · line 140 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @fallthrough:0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json) -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def rotate_do source · line 145 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+slot:String -> @+label:String -> @+warns:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def rotate_out source · line 150 · raw
@+s:0x0717344745a30ebad1f19045228e8f18/swpick.Sel -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def rotate_run2 source · line 161 · raw
@+anchor:Maybe<&2, String> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def rotate_run source · line 166 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def auto4 source · line 169 · raw
@+strategy:String -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+curref:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def usage_json source · line 174 · raw
@+u:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def auto3 source · line 177 · raw
@+strategy:String -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+email:String -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def auto2 source · line 182 · raw
@+strategy:String -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+cur:Maybe<&2, String> -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def preferred2 source · line 191 · raw
@+active:Maybe<&2, String> -> @+slots:List<&2, String> -> Maybe<&2, String>
def preferred source · line 199 · raw
@+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> Maybe<&2, String>
Switch with nobody logged in: the active slot, else the first.
def reason_of source · line 202 · raw
@+c:0x0717344745a30ebad1f19045228e8f18/swpick.Cand -> String
def any_switchable source · line 207 · raw
@+cs:List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand> -> Bool
def fallback_out source · line 214 · raw
@+s:0x0717344745a30ebad1f19045228e8f18/swpick.Sel -> @+all_cs:List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+warn:String -> @+label:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def logged_out3 source · line 221 · raw
@+c:0x0717344745a30ebad1f19045228e8f18/swpick.Cand -> @+rest:List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+label:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def logged_out2 source · line 228 · raw
@+cs:List<&2, 0x0717344745a30ebad1f19045228e8f18/swpick.Cand> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+label:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def logged_out4 source · line 235 · raw
@+m:Maybe<&2, String> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+label:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def logged_out source · line 244 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+label:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def auto_branch source · line 247 · raw
@+strategy:String -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def auto1 source · line 250 · raw
@+strategy:String -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+label:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def switch_auto source · line 266 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+strategy:String -> @+models:List<&2, String> -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
cswap switch [--strategy best|next-available] [--model NAMES]: strategy
"" rotates through sequence; "next-available" also skips accounts with no
headroom; "best" moves to the account with strictly more headroom. Usage is
read from cache/usage.json as it stands (no fetch). A logged-out machine
activates the active (else first) slot. The result is the object of
contract 2.3; no-op outcomes are results, not errors. A live unmanaged login
is reported as unmanaged-account (the CLI adds it with Store.add_current).