if {$argc != 1} { puts stderr "Usage: $argv0 " 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