@@ -24,11 +24,21 @@ struct Cli {
2424 clickhouse : Option < String > ,
2525
2626 /// ClickHouse user
27- #[ arg( long, env = "CG_CLICKHOUSE_USER" , global = true , default_value = "default" ) ]
27+ #[ arg(
28+ long,
29+ env = "CG_CLICKHOUSE_USER" ,
30+ global = true ,
31+ default_value = "default"
32+ ) ]
2833 ch_user : String ,
2934
3035 /// ClickHouse password
31- #[ arg( long, env = "CG_CLICKHOUSE_PASSWORD" , global = true , default_value = "" ) ]
36+ #[ arg(
37+ long,
38+ env = "CG_CLICKHOUSE_PASSWORD" ,
39+ global = true ,
40+ default_value = ""
41+ ) ]
3242 ch_password : String ,
3343
3444 /// ClickHouse database to query
@@ -139,7 +149,13 @@ enum SchemaCommands {
139149#[ tokio:: main]
140150async fn main ( ) -> Result < ( ) > {
141151 let cli = Cli :: parse ( ) ;
142- let cfg = CgConfig :: load ( & cli. schema , & cli. clickhouse , & cli. ch_user , & cli. ch_password , & cli. ch_database ) ?;
152+ let cfg = CgConfig :: load (
153+ & cli. schema ,
154+ & cli. clickhouse ,
155+ & cli. ch_user ,
156+ & cli. ch_password ,
157+ & cli. ch_database ,
158+ ) ?;
143159
144160 match cli. command {
145161 Commands :: Sql { query } => {
@@ -150,11 +166,19 @@ async fn main() -> Result<()> {
150166 commands:: query:: run_validate ( & query, & cfg) ?;
151167 }
152168
153- Commands :: Query { query, sql_only, format } => {
169+ Commands :: Query {
170+ query,
171+ sql_only,
172+ format,
173+ } => {
154174 commands:: query:: run_query ( & query, sql_only, & format, & cfg) . await ?;
155175 }
156176
157- Commands :: Nl { description, execute, format } => {
177+ Commands :: Nl {
178+ description,
179+ execute,
180+ format,
181+ } => {
158182 commands:: nl:: run_nl ( & description, execute, & format, & cfg) . await ?;
159183 }
160184
@@ -163,16 +187,34 @@ async fn main() -> Result<()> {
163187 commands:: schema:: run_show ( & format, & cfg) ?;
164188 }
165189 SchemaCommands :: Validate { file } => {
166- let path = file
167- . or_else ( || cfg. schema_path . clone ( ) )
168- . ok_or_else ( || anyhow:: anyhow!( "No schema file specified. Use --schema or provide a file argument." ) ) ?;
190+ let path = file. or_else ( || cfg. schema_path . clone ( ) ) . ok_or_else ( || {
191+ anyhow:: anyhow!(
192+ "No schema file specified. Use --schema or provide a file argument."
193+ )
194+ } ) ?;
169195 commands:: schema:: run_validate_schema ( & path) ?;
170196 }
171- SchemaCommands :: Discover { database, clickhouse, user, password, out } => {
197+ SchemaCommands :: Discover {
198+ database,
199+ clickhouse,
200+ user,
201+ password,
202+ out,
203+ } => {
172204 let ch_url = clickhouse
173205 . or_else ( || cfg. clickhouse_url . clone ( ) )
174- . ok_or_else ( || anyhow:: anyhow!( "No ClickHouse URL. Use --clickhouse or CG_CLICKHOUSE_URL." ) ) ?;
175- commands:: schema:: run_discover ( & database, & ch_url, & user, & password, out. as_deref ( ) , & cfg) . await ?;
206+ . ok_or_else ( || {
207+ anyhow:: anyhow!( "No ClickHouse URL. Use --clickhouse or CG_CLICKHOUSE_URL." )
208+ } ) ?;
209+ commands:: schema:: run_discover (
210+ & database,
211+ & ch_url,
212+ & user,
213+ & password,
214+ out. as_deref ( ) ,
215+ & cfg,
216+ )
217+ . await ?;
176218 }
177219 SchemaCommands :: Diff { old, new } => {
178220 commands:: schema:: run_diff ( & old, & new) ?;
0 commit comments