@@ -16,11 +16,6 @@ def init_ruff_toml():
1616 click .echo (f"Created { ruff_toml_path } " )
1717
1818
19- def init_website ():
20- click .echo (f"Initializing project website template in { ap .paths .website_path } ..." )
21- subprocess .run (["ap" , "update" , "website" ])
22-
23-
2419def init_py_typed ():
2520 from afterpython .tools .pyproject import find_package_directory
2621
@@ -39,7 +34,7 @@ def init_py_typed():
3934 click .echo (f"Created { py_typed_path } " )
4035
4136
42- @click .command ( )
37+ @click .group ( invoke_without_command = True )
4338@click .option (
4439 "--yes" ,
4540 "-y" ,
@@ -49,18 +44,20 @@ def init_py_typed():
4944@click .option (
5045 "--skip-website" ,
5146 is_flag = True ,
52- help = "Skip website template initialization" ,
47+ help = "Skip website template initialization (run `ap init website` later to add it) " ,
5348)
5449@click .pass_context
5550def init (ctx , yes , skip_website : bool ):
5651 """Initialize AfterPython project structure and website template"""
52+ if ctx .invoked_subcommand is not None :
53+ return
54+
5755 from afterpython .tools ._afterpython import init_afterpython
5856 from afterpython .tools .commitizen import init_commitizen
5957 from afterpython .tools .github_actions import (
6058 create_dependabot ,
6159 create_workflow ,
6260 )
63- from afterpython .tools .myst import init_myst
6461 from afterpython .tools .pre_commit import init_pre_commit
6562 from afterpython .tools .pyproject import init_pyproject
6663
@@ -77,10 +74,7 @@ def init(ctx, yes, skip_website: bool):
7774 init_afterpython ()
7875
7976 if not skip_website :
80- # TODO: init faq.yml
81- init_myst ()
82- init_website ()
83- create_workflow ("deploy" )
77+ subprocess .run (["ap" , "init" , "website" ])
8478
8579 # TODO: add type checking related stuff here
8680 init_py_typed ()
@@ -109,3 +103,20 @@ def init(ctx, yes, skip_website: bool):
109103 default = True ,
110104 ):
111105 create_dependabot ()
106+
107+
108+ @init .command ("website" )
109+ def init_website_subcommand ():
110+ """Initialize project website (MyST config, template, deploy workflow)
111+
112+ Use this if you ran `ap init --skip-website` and now want to add
113+ the website to an existing AfterPython project.
114+ """
115+ from afterpython .tools .github_actions import create_workflow
116+ from afterpython .tools .myst import init_myst
117+
118+ # TODO: init faq.yml
119+ init_myst ()
120+ click .echo (f"Initializing project website template in { ap .paths .website_path } ..." )
121+ subprocess .run (["ap" , "update" , "website" ])
122+ create_workflow ("deploy" )
0 commit comments