Skip to content

Commit bd2d01a

Browse files
authored
Merge pull request #278 from tcdent/init-ask-project
Ask the user for a project slug_name on init if none is provided
2 parents b05971d + 43cfe84 commit bd2d01a

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

agentstack/cli/init.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,31 @@ def init_project(
7676
- install dependencies
7777
- insert Tasks, Agents and Tools
7878
"""
79+
# TODO prevent the user from passing the --path argument to init
80+
if template and use_wizard:
81+
raise Exception("Template and wizard flags cannot be used together")
82+
7983
require_uv()
84+
welcome_message()
8085

81-
# TODO prevent the user from passing the --path argument to init
82-
if slug_name:
83-
if not is_snake_case(slug_name):
84-
raise Exception("Project name must be snake_case")
85-
conf.set_path(conf.PATH / slug_name)
86-
else:
87-
raise Exception("No project directory specified.\n Run `agentstack init <project_name>`")
86+
if not slug_name:
87+
log.info(
88+
"Provide a project name. This will be used to create a new directory in the "
89+
"current path and will be used as the project name. 🐍 Must be snake_case."
90+
)
91+
slug_name = inquirer.text(
92+
message="Project name (snake_case)",
93+
)
94+
95+
if not slug_name:
96+
raise Exception("Project name cannot be empty")
97+
if not is_snake_case(slug_name):
98+
raise Exception("Project name must be snake_case")
8899

100+
conf.set_path(conf.PATH / slug_name)
89101
if os.path.exists(conf.PATH): # cookiecutter requires the directory to not exist
90102
raise Exception(f"Directory already exists: {conf.PATH}")
91103

92-
if template and use_wizard:
93-
raise Exception("Template and wizard flags cannot be used together")
94-
95-
welcome_message()
96-
97104
if use_wizard:
98105
log.debug("Initializing new project with wizard.")
99106
template_data = run_wizard(slug_name)

0 commit comments

Comments
 (0)