1010from codegen .cli .commands .init .render import get_success_message
1111from codegen .cli .git .url import get_git_organization_and_repo
1212from codegen .cli .rich .codeblocks import format_command
13+ from codegen .cli .utils .constants import ProgrammingLanguage
1314from codegen .cli .workspace .initialize_workspace import initialize_codegen
1415
1516
1617@click .command (name = "init" )
1718@click .option ("--repo-name" , type = str , help = "The name of the repository" )
1819@click .option ("--organization-name" , type = str , help = "The name of the organization" )
1920@click .option ("--fetch-docs" , is_flag = True , help = "Fetch docs and examples (requires auth)" )
20- def init_command (repo_name : str | None = None , organization_name : str | None = None , fetch_docs : bool = False ):
21+ @click .option ("--language" , type = click .Choice (["python" , "typescript" ], case_sensitive = False ), help = "Override automatic language detection" )
22+ def init_command (repo_name : str | None = None , organization_name : str | None = None , fetch_docs : bool = False , language : str | None = None ):
2123 """Initialize or update the Codegen folder."""
2224 # Print a message if not in a git repo
2325 try :
@@ -31,6 +33,11 @@ def init_command(repo_name: str | None = None, organization_name: str | None = N
3133 rich .print (format_command ("codegen init" ))
3234 sys .exit (1 )
3335
36+ # Convert language string to enum if provided
37+ programming_language = None
38+ if language :
39+ programming_language = ProgrammingLanguage [language .upper ()]
40+
3441 # Only create session if we need to fetch docs
3542 session = CodegenSession () if fetch_docs else None
3643 codegen_dir = Path .cwd () / CODEGEN_DIR if not session else session .codegen_dir
@@ -46,11 +53,13 @@ def init_command(repo_name: str | None = None, organization_name: str | None = N
4653 cwd_org , cwd_repo = get_git_organization_and_repo (session .git_repo )
4754 session .config .organization_name = session .config .organization_name or cwd_org
4855 session .config .repo_name = session .config .repo_name or cwd_repo
56+ if programming_language :
57+ session .config .programming_language = programming_language
4958 session .write_config ()
5059
5160 action = "Updating" if is_update else "Initializing"
52- rich .print ("" ) # Add a newline before the spinner
53- codegen_dir , docs_dir , examples_dir = initialize_codegen (action , session = session , fetch_docs = fetch_docs )
61+ rich .print ("" )
62+ codegen_dir , docs_dir , examples_dir = initialize_codegen (action , session = session , fetch_docs = fetch_docs , programming_language = programming_language )
5463
5564 # Print success message
5665 rich .print (f"✅ { action } complete\n " )
0 commit comments