3838from reflex import constants , model
3939from reflex .compiler import templates
4040from reflex .config import Config , environment , get_config
41- from reflex .utils import console , net , path_ops , processes
41+ from reflex .utils import console , net , path_ops , processes , redir
4242from reflex .utils .decorator import once
4343from reflex .utils .exceptions import (
4444 GeneratedCodeHasNoFunctionDefsError ,
@@ -65,7 +65,6 @@ class Template:
6565 name : str
6666 description : str
6767 code_url : str
68- demo_url : str | None = None
6968
7069
7170@dataclasses .dataclass (frozen = True )
@@ -1606,22 +1605,13 @@ def prompt_for_template_options(templates: list[Template]) -> str:
16061605 # Show the user the URLs of each template to preview.
16071606 console .print ("\n Get started with a template:" )
16081607
1609- def format_demo_url_str (url : str | None ) -> str :
1610- return f" ({ url } )" if url else ""
1611-
16121608 # Prompt the user to select a template.
1613- id_to_name = {
1614- str (
1615- idx
1616- ): f"{ template .name .replace ('_' , ' ' ).replace ('-' , ' ' )} { format_demo_url_str (template .demo_url )} - { template .description } "
1617- for idx , template in enumerate (templates )
1618- }
1619- for id in range (len (id_to_name )):
1620- console .print (f"({ id } ) { id_to_name [str (id )]} " )
1609+ for index , template in enumerate (templates ):
1610+ console .print (f"({ index } ) { template .description } " )
16211611
16221612 template = console .ask (
16231613 "Which template would you like to use?" ,
1624- choices = [str (i ) for i in range (len (id_to_name ))],
1614+ choices = [str (i ) for i in range (len (templates ))],
16251615 show_choices = False ,
16261616 default = "0" ,
16271617 )
@@ -1890,14 +1880,17 @@ def initialize_app(app_name: str, template: str | None = None) -> str | None:
18901880
18911881 if template is None :
18921882 template = prompt_for_template_options (get_init_cli_prompt_options ())
1883+
18931884 if template == constants .Templates .CHOOSE_TEMPLATES :
1894- console .print (
1895- f"Go to the templates page ({ constants .Templates .REFLEX_TEMPLATES_URL } ) and copy the command to init with a template."
1896- )
1885+ redir .reflex_templates ()
18971886 raise click .exceptions .Exit (0 )
18981887
1888+ if template == constants .Templates .AI :
1889+ redir .reflex_build_redirect ()
1890+ raise click .exceptions .Exit (0 )
1891+
18991892 # If the blank template is selected, create a blank app.
1900- if template in ( constants .Templates .DEFAULT ,) :
1893+ if template == constants .Templates .DEFAULT :
19011894 # Default app creation behavior: a blank app.
19021895 initialize_default_app (app_name )
19031896 else :
@@ -1920,19 +1913,16 @@ def get_init_cli_prompt_options() -> list[Template]:
19201913 Template (
19211914 name = constants .Templates .DEFAULT ,
19221915 description = "A blank Reflex app." ,
1923- demo_url = constants .Templates .DEFAULT_TEMPLATE_URL ,
19241916 code_url = "" ,
19251917 ),
19261918 Template (
19271919 name = constants .Templates .AI ,
1928- description = "Generate a template using AI [Experimental]" ,
1929- demo_url = "" ,
1920+ description = "[bold]Try our free AI builder." ,
19301921 code_url = "" ,
19311922 ),
19321923 Template (
19331924 name = constants .Templates .CHOOSE_TEMPLATES ,
1934- description = "Choose an existing template." ,
1935- demo_url = "" ,
1925+ description = "Premade templates built by the Reflex team." ,
19361926 code_url = "" ,
19371927 ),
19381928 ]
0 commit comments