@@ -1325,22 +1325,27 @@ def _init_integer_prompt(
13251325 return option_num
13261326
13271327
1328+ def _init_display_choices (values_dict : t .Dict [str , str ], console : Console ) -> t .Dict [int , str ]:
1329+ display_num_to_value = {}
1330+ for i , value_str in enumerate (values_dict .keys ()):
1331+ console .print (f" \[{ i + 1 } ] { value_str } { values_dict [value_str ]} " )
1332+ display_num_to_value [i + 1 ] = value_str
1333+ console .print ("" )
1334+ return display_num_to_value
1335+
1336+
13281337def _init_template_prompt (console : Console ) -> ProjectTemplate :
1338+ console .print ("──────────────────────────────\n " )
1339+ console .print ("What type of project do you want to set up?\n " )
1340+
13291341 # These are ordered for user display - do not reorder
13301342 template_descriptions = {
13311343 ProjectTemplate .DEFAULT .name : "- Create SQLMesh example project models and files" ,
13321344 ProjectTemplate .DBT .value : " - You have an existing dbt project and want to run it with SQLMesh" ,
13331345 ProjectTemplate .EMPTY .name : " - Create a SQLMesh configuration file and project directories only" ,
13341346 }
13351347
1336- console .print ("──────────────────────────────\n " )
1337- console .print ("What type of project do you want to set up?\n " )
1338-
1339- display_num_to_template = {}
1340- for i , template_str in enumerate (template_descriptions .keys ()):
1341- console .print (f" \[{ i + 1 } ] { template_str } { template_descriptions [template_str ]} " )
1342- display_num_to_template [i + 1 ] = template_str
1343- console .print ("" )
1348+ display_num_to_template = _init_display_choices (template_descriptions , console )
13441349
13451350 template_num = _init_integer_prompt (
13461351 console , "project type" , len (template_descriptions ), _init_template_prompt
@@ -1354,37 +1359,29 @@ def _init_engine_prompt(console: Console) -> str:
13541359 console .print ("Choose your SQL engine:\n " )
13551360
13561361 # INIT_DISPLAY_INFO_TO_TYPE is a dict of {engine_type: (display_order, display_name)}
1357- ordered_engine_display_names = [
1358- info [1 ] for info in sorted (INIT_DISPLAY_INFO_TO_TYPE .values (), key = lambda x : x [0 ])
1359- ]
1360- display_num_to_display_name = {}
1361- for i , display_name in enumerate (ordered_engine_display_names ):
1362- console .print (f" \\ [{ i + 1 } ] { ' ' if i < 9 else '' } { display_name } " )
1363- display_num_to_display_name [i + 1 ] = display_name
1364- console .print ("" )
1362+ DISPLAY_NAME_TO_TYPE = {v [1 ]: k for k , v in INIT_DISPLAY_INFO_TO_TYPE .items ()}
1363+ ordered_engine_display_names = {
1364+ info [1 ]: "" for info in sorted (INIT_DISPLAY_INFO_TO_TYPE .values (), key = lambda x : x [0 ])
1365+ }
1366+ display_num_to_display_name = _init_display_choices (ordered_engine_display_names , console )
13651367
13661368 engine_num = _init_integer_prompt (
13671369 console , "engine" , len (ordered_engine_display_names ), _init_engine_prompt
13681370 )
13691371
1370- DISPLAY_NAME_TO_TYPE = {v [1 ]: k for k , v in INIT_DISPLAY_INFO_TO_TYPE .items ()}
13711372 return DISPLAY_NAME_TO_TYPE [display_num_to_display_name [engine_num ]]
13721373
13731374
13741375def _init_cli_mode_prompt (console : Console ) -> InitCliMode :
1376+ console .print ("──────────────────────────────\n " )
1377+ console .print ("Choose your SQLMesh CLI experience:\n " )
1378+
13751379 cli_mode_descriptions = {
13761380 InitCliMode .DEFAULT .name : "- See and control every detail" ,
13771381 InitCliMode .SIMPLE .name : " - Automatically run changes and show summary output" ,
13781382 }
13791383
1380- console .print ("──────────────────────────────\n " )
1381- console .print ("Choose your SQLMesh CLI experience:\n " )
1382-
1383- display_num_to_cli_mode = {}
1384- for i , cli_mode in enumerate (cli_mode_descriptions .keys ()):
1385- console .print (f" \[{ i + 1 } ] { cli_mode } { cli_mode_descriptions [cli_mode ]} " )
1386- display_num_to_cli_mode [i + 1 ] = cli_mode
1387- console .print ("" )
1384+ display_num_to_cli_mode = _init_display_choices (cli_mode_descriptions , console )
13881385
13891386 cli_mode_num = _init_integer_prompt (
13901387 console , "config" , len (cli_mode_descriptions ), _init_cli_mode_prompt
0 commit comments