tui/model.bend
cswap-bend-cli@0.1.0.0 · 77 lines · 15 definitions
1import Base
2
3
4
5
6
7
8type Win is Data:
9 Win{label: String, pct: Maybe<&2, U32>, reset: Maybe<&2, U32>}
10
11
12
13type Acct is Data:
14 Acct{slot: String, email: String, alias: String, tag: String, active: Bool, disabled: Bool, wins: List<&2, Win>, age: Maybe<&2, U32>, note: String}
15
16
17type Hdr is Data:
18 Hdr{version: String, live: Bool, pid: Maybe<&2, U32>, threshold: Maybe<&2, U32>, interval: Maybe<&2, U32>, next_poll: Maybe<&2, U32>}
19
20
21
22type Snap is Data:
23 Snap{now: U32, off: U32, hdr: Hdr, accts: List<&2, Acct>, log: List<&2, String>}
24
25
26type View is Data:
27 View{width: U32, color: Bool}
28
29def win_label(+w: Win) -> String:
30 match w:
31 case Win{l, p, r}:
32 l
33
34def win_pct(+w: Win) -> Maybe<&2, U32>:
35 match w:
36 case Win{l, p, r}:
37 p
38
39def win_reset(+w: Win) -> Maybe<&2, U32>:
40 match w:
41 case Win{l, p, r}:
42 r
43
44def acct_wins(+a: Acct) -> List<&2, Win>:
45 match a:
46 case Acct{s, e, al, t, ac, d, w, g, n}:
47 w
48
49def acct_slot(+a: Acct) -> String:
50 match a:
51 case Acct{s, e, al, t, ac, d, w, g, n}:
52 s
53
54def acct_active(+a: Acct) -> Bool:
55 match a:
56 case Acct{s, e, al, t, ac, d, w, g, n}:
57 ac
58
59def acct_disabled(+a: Acct) -> Bool:
60 match a:
61 case Acct{s, e, al, t, ac, d, w, g, n}:
62 d
63
64def acct_email(+a: Acct) -> String:
65 match a:
66 case Acct{s, e, al, t, ac, d, w, g, n}:
67 e
68
69def acct_age(+a: Acct) -> Maybe<&2, U32>:
70 match a:
71 case Acct{s, e, al, t, ac, d, w, g, n}:
72 g
73
74def acct_note(+a: Acct) -> String:
75 match a:
76 case Acct{s, e, al, t, ac, d, w, g, n}:
77 n