|
1 |
| -module Env = { |
2 |
| - @set |
3 |
| - external setTheme: (Bun.Env.t, string) => unit = "BETTER_TMUX_THEME" |
4 |
| -} |
5 |
| - |
6 |
| -let createRoot = exec => { |
7 |
| - let root: Reconcilier.root = { |
8 |
| - mount: tree => { |
9 |
| - let body = Parser.make(tree) |
10 |
| - exec(body) |
11 |
| - }, |
12 |
| - } |
13 |
| - |
14 |
| - root |
15 |
| -} |
16 |
| - |
17 |
| -module Roots = { |
18 |
| - let statusLeft = createRoot(body => Tmux.exec(SetGlobal(StatusLeft(body)))) |
19 |
| - let statusRight = createRoot(body => Tmux.exec(SetGlobal(StatusRight(body)))) |
20 |
| - let activeWindow = createRoot(body => Tmux.exec(SetGlobal(WindowStatusCurrentFormat(body)))) |
21 |
| - let normalWindow = createRoot(body => Tmux.exec(SetGlobal(WindowStatusFormat(body)))) |
22 |
| -} |
23 |
| - |
24 |
| -type windowType = [ |
25 |
| - | #active |
26 |
| - | #normal |
27 |
| -] |
28 |
| - |
29 |
| -type windowParams = { |
30 |
| - @as("type") type_: windowType, |
31 |
| - number: string, |
32 |
| - name: string, |
33 |
| -} |
34 |
| - |
35 |
| -type window = windowParams => TmuxJsx.element |
36 |
| - |
37 |
| -type config = { |
38 |
| - theme: option<string>, |
39 |
| - statusLeft: option<TmuxJsx.element>, |
40 |
| - statusRight: option<TmuxJsx.element>, |
41 |
| - window: option<window>, |
42 |
| -} |
43 |
| -type mod = {default: config} |
44 |
| - |
45 |
| -type flags<'value> = {file: 'value} |
46 |
| - |
47 |
| -module Window = { |
48 |
| - let render = (window: window) => { |
49 |
| - Reconcilier.render( |
50 |
| - window({ |
51 |
| - type_: #active, |
52 |
| - name: "#W", |
53 |
| - number: "#I", |
54 |
| - }), |
55 |
| - Roots.activeWindow, |
56 |
| - ) |
57 |
| - |
58 |
| - Reconcilier.render( |
59 |
| - window({ |
60 |
| - type_: #normal, |
61 |
| - name: "#W", |
62 |
| - number: "#I", |
63 |
| - }), |
64 |
| - Roots.normalWindow, |
65 |
| - ) |
66 |
| - } |
67 |
| -} |
68 |
| - |
69 |
| -@val external import_: string => promise<mod> = "import" |
70 |
| - |
71 |
| -let run = async () => { |
72 |
| - |
73 |
| - let options: flags<BunX.flag> = { |
74 |
| - file: {type_: "string"}, |
75 |
| - } |
76 |
| - |
77 |
| - let {values}: BunX.parseArgs<flags<string>> = BunX.parseArgs({ |
78 |
| - args: Bun.argv, |
79 |
| - options, |
80 |
| - strict: true, |
81 |
| - allowPositionals: true, |
82 |
| - }) |
83 |
| - |
84 |
| - let path = Path.resolve([values.file]) |
85 |
| - let {default: config} = await import_(path) |
86 |
| - |
87 |
| - Env.setTheme(Bun.env, config.theme->Option.getOr("catppuccin-mocha")) |
88 |
| - |
89 |
| - switch config.statusLeft { |
90 |
| - | None => () |
91 |
| - | Some(statusLeft) => Reconcilier.render(statusLeft, Roots.statusLeft) |
92 |
| - } |
93 |
| - |
94 |
| - switch config.statusRight { |
95 |
| - | None => () |
96 |
| - | Some(statusRight) => Reconcilier.render(statusRight, Roots.statusRight) |
97 |
| - } |
98 |
| - |
99 |
| - switch config.window { |
100 |
| - | None => () |
101 |
| - | Some(window) => Window.render(window) |
102 |
| - } |
103 |
| - |
104 |
| -} |
105 |
| - |
106 |
| -run()->ignore |
| 1 | +Runner.run()->ignore |
0 commit comments