@@ -2,13 +2,14 @@ use anyhow::Result;
22use backtrace:: Backtrace ;
33use flexi_logger:: { LogSpecification , Logger } ;
44use std:: panic:: { self , PanicHookInfo } ;
5+ use std:: sync:: Arc ;
56
67mod common;
78mod interpreter;
89mod view;
910
1011use crate :: {
11- interpreter:: { options, Context , ContextArc } ,
12+ interpreter:: { options, ClickHouse , Context , ContextArc } ,
1213 view:: Navigation ,
1314} ;
1415
@@ -37,6 +38,10 @@ fn panic_hook(info: &PanicHookInfo<'_>) {
3738async fn main ( ) -> Result < ( ) > {
3839 let options = options:: parse ( ) ;
3940
41+ // Initialize it before any backends (otherwise backend will prepare terminal for TUI app, and
42+ // panic hook will clear the screen).
43+ let clickhouse = Arc :: new ( ClickHouse :: new ( options. clickhouse . clone ( ) ) . await ?) ;
44+
4045 panic:: set_hook ( Box :: new ( |info| {
4146 panic_hook ( info) ;
4247 } ) ) ;
@@ -63,7 +68,7 @@ async fn main() -> Result<()> {
6368 . start ( ) ?;
6469
6570 // FIXME: should be initialized before cursive, otherwise on error it clears the terminal.
66- let context: ContextArc = Context :: new ( options, siv. cb_sink ( ) . clone ( ) ) . await ?;
71+ let context: ContextArc = Context :: new ( options, clickhouse , siv. cb_sink ( ) . clone ( ) ) . await ?;
6772
6873 siv. chdig ( context. clone ( ) ) ;
6974
0 commit comments