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