~aleteoryx/tclircc

ref: 1c9eee37d59cadc5728509594b0fc666f3fa510c tclircc/main.tcl -rwxr-xr-x 1.3 KiB
1c9eee37aleteoryx manifest loading basics a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/env tclsh

set path [file dirname [dict get [info frame 0] file]]
set version v0.0.1

package require Thread
package require logger
set log [logger::init tclircc::main]
package require sqlite3

${log}::info "tclircc $version <https://amehut.dev/~aleteoryx/tclircc>"
${log}::info "running from $path"

source threads.tcl

proc start_thread {name} {
  global path
  global version
  global log

  ${log}::debug "starting $name thread..."

  set thread [thread::create -preserved]
  threads::manage $thread tclircc::$name
  thread::send $thread [list variable path $path version $version]

  if {[thread::send $thread [list source "$path[file separator]$name[file separator]main.tcl"] result] == 1} {
    ${log}::critical "couldn't start $name thread: $result"
    exit -1
  }

  ${log}::debug "started $name thread."
}

start_thread db

thread::send [t::ns tclircc::db] {path_to_core} core_db_path
sqlite3 core_db $core_db_path -create true -fullmutex true
source migrate_core.tcl

source plugins.tcl

start_thread irc
start_thread ui

plugins::load "$path[file separator]testplugin"

${log}::debug "opening initial window..."
thread::send [t::ns tclircc::ui] {mk_toplevel name; return $name} initial
${log}::debug "initial window opened: $initial"

threads::debug

${log}::info "entering event loop"
vwait nil