@@ -1303,22 +1303,27 @@ def _init_integer_prompt(
13031303 return option_num
13041304
13051305
1306+ def _init_display_choices (values_dict : t .Dict [str , str ], console : Console ) -> t .Dict [int , str ]:
1307+ display_num_to_value = {}
1308+ for i , value_str in enumerate (values_dict .keys ()):
1309+ console .print (f" \[{ i + 1 } ] { value_str } { values_dict [value_str ]} " )
1310+ display_num_to_value [i + 1 ] = value_str
1311+ console .print ("" )
1312+ return display_num_to_value
1313+
1314+
13061315def _init_template_prompt (console : Console ) -> ProjectTemplate :
1316+ console .print ("──────────────────────────────\n " )
1317+ console .print ("What type of project do you want to set up?\n " )
1318+
13071319 # These are ordered for user display - do not reorder
13081320 template_descriptions = {
13091321 ProjectTemplate .DEFAULT .name : "- Create SQLMesh example project models and files" ,
13101322 ProjectTemplate .DBT .value : " - You have an existing dbt project and want to run it with SQLMesh" ,
13111323 ProjectTemplate .EMPTY .name : " - Create a SQLMesh configuration file and project directories only" ,
13121324 }
13131325
1314- console .print ("──────────────────────────────\n " )
1315- console .print ("What type of project do you want to set up?\n " )
1316-
1317- display_num_to_template = {}
1318- for i , template_str in enumerate (template_descriptions .keys ()):
1319- console .print (f" \[{ i + 1 } ] { template_str } { template_descriptions [template_str ]} " )
1320- display_num_to_template [i + 1 ] = template_str
1321- console .print ("" )
1326+ display_num_to_template = _init_display_choices (template_descriptions , console )
13221327
13231328 template_num = _init_integer_prompt (
13241329 console , "project type" , len (template_descriptions ), _init_template_prompt
@@ -1332,37 +1337,29 @@ def _init_engine_prompt(console: Console) -> str:
13321337 console .print ("Choose your SQL engine:\n " )
13331338
13341339 # INIT_DISPLAY_INFO_TO_TYPE is a dict of {engine_type: (display_order, display_name)}
1335- ordered_engine_display_names = [
1336- info [1 ] for info in sorted (INIT_DISPLAY_INFO_TO_TYPE .values (), key = lambda x : x [0 ])
1337- ]
1338- display_num_to_display_name = {}
1339- for i , display_name in enumerate (ordered_engine_display_names ):
1340- console .print (f" \\ [{ i + 1 } ] { ' ' if i < 9 else '' } { display_name } " )
1341- display_num_to_display_name [i + 1 ] = display_name
1342- console .print ("" )
1340+ DISPLAY_NAME_TO_TYPE = {v [1 ]: k for k , v in INIT_DISPLAY_INFO_TO_TYPE .items ()}
1341+ ordered_engine_display_names = {
1342+ info [1 ]: "" for info in sorted (INIT_DISPLAY_INFO_TO_TYPE .values (), key = lambda x : x [0 ])
1343+ }
1344+ display_num_to_display_name = _init_display_choices (ordered_engine_display_names , console )
13431345
13441346 engine_num = _init_integer_prompt (
13451347 console , "engine" , len (ordered_engine_display_names ), _init_engine_prompt
13461348 )
13471349
1348- DISPLAY_NAME_TO_TYPE = {v [1 ]: k for k , v in INIT_DISPLAY_INFO_TO_TYPE .items ()}
13491350 return DISPLAY_NAME_TO_TYPE [display_num_to_display_name [engine_num ]]
13501351
13511352
13521353def _init_cli_mode_prompt (console : Console ) -> InitCliMode :
1354+ console .print ("──────────────────────────────\n " )
1355+ console .print ("Choose your SQLMesh CLI experience:\n " )
1356+
13531357 cli_mode_descriptions = {
13541358 InitCliMode .DEFAULT .name : "- See and control every detail" ,
13551359 InitCliMode .SIMPLE .name : " - Automatically run changes and show summary output" ,
13561360 }
13571361
1358- console .print ("──────────────────────────────\n " )
1359- console .print ("Choose your SQLMesh CLI experience:\n " )
1360-
1361- display_num_to_cli_mode = {}
1362- for i , cli_mode in enumerate (cli_mode_descriptions .keys ()):
1363- console .print (f" \[{ i + 1 } ] { cli_mode } { cli_mode_descriptions [cli_mode ]} " )
1364- display_num_to_cli_mode [i + 1 ] = cli_mode
1365- console .print ("" )
1362+ display_num_to_cli_mode = _init_display_choices (cli_mode_descriptions , console )
13661363
13671364 cli_mode_num = _init_integer_prompt (
13681365 console , "config" , len (cli_mode_descriptions ), _init_cli_mode_prompt
0 commit comments