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
if {$argc != 1} {
puts stderr "Usage: $argv0 </path/to/config/file.ini>"
exit -1
}
if [catch {set config [::ini::open [lindex $argv 0] r]} result] {
puts stderr "Couldn't open config: $result"
exit -1
}
namespace eval ::config {
variable log [logger::init "tclfeed::config"]
proc require {config section key} {
variable log
if ![::ini::exists $config $section $key] {
puts stderr "Missing [$section/$key] in config!"
exit -2
}
${log}::info "\[$section/$key\] = [::ini::value $config $section $key]"
}
proc optional {config section key value} {
variable log
if ![::ini::exists $config $section $key] {
::ini::set $config $section $key $value
${log}::info "\[$section/$key\] = [::ini::value $config $section $key] (default)"
} else {
${log}::info "\[$section/$key\] = [::ini::value $config $section $key]"
}
}
proc check {config} {
variable log
${log}::info "Loading config [::ini::filename $config]..."
require $config database path
optional $config database max_posts 10000
optional $config database cleanup_interval 600
require $config atproto jetstream_host
require $config atproto publisher_did
require $config atproto self_host
optional $config httpd port 3000
${log}::info "Config loaded!..."
}
}
config::check $config