@@ -120,7 +120,7 @@ def init(interactive: bool, framework: str, dbt_path: str, output_dir: str, forc
120120
121121def _interactive_setup () -> Dict [str , Any ]:
122122 """Interactive setup wizard with directory support."""
123- click .echo ("📋 Quick Setup (3 questions):" )
123+ click .echo ("📋 Quick Setup (a handful of questions):" )
124124 click .echo ()
125125
126126 # Question 1: DBT project location
@@ -148,57 +148,46 @@ def _interactive_setup() -> Dict[str, Any]:
148148 show_default = True ,
149149 )
150150
151- # Question 3: API models location with directory support
152- click .echo ()
153151 if framework == "fastapi" :
154152 default_path = "app/models" # Default to directory
155- prompt_text = "3️⃣ Where are your Pydantic models? (file or directory)"
156- help_text = (
157- " 💡 Examples: 'app/models.py' (single file) or 'app/models' (directory)"
158- )
153+ location_noun = "Pydantic models"
159154 elif framework == "django" :
160155 default_path = "models.py"
161- prompt_text = "3️⃣ Where are your Django models?"
162- help_text = " 💡 Examples: 'myapp/models.py' or 'models'"
156+ location_noun = "Django models"
163157 else :
164158 default_path = "models"
165- prompt_text = "3️⃣ Where are your API models?"
166- help_text = " 💡 Can be a file (models.py) or directory (models/)"
167-
168- click .echo (help_text )
169- api_location = click .prompt (prompt_text , default = default_path , show_default = True )
170-
171- # Auto-detect if it's local file/directory or GitHub repo. A local
172- # relative path like "app/models" is syntactically identical to a GitHub
173- # "org/repo" string, so check disk first -- and only ask when it's
174- # genuinely ambiguous (doesn't exist locally, but still looks like it
175- # could be either).
176- local_path = Path (api_location )
177- looks_like_repo = "/" in api_location and not api_location .startswith (("." , "/" ))
178-
179- if local_path .exists ():
180- is_github_repo = False
181- elif looks_like_repo :
182- is_github_repo = click .confirm (
183- f" '{ api_location } ' doesn't exist locally — is this a GitHub "
184- f"repo (org/repo) rather than a local path?" ,
185- default = True ,
159+ location_noun = "API models"
160+
161+ # Question 3: local vs. GitHub -- asked explicitly rather than guessed
162+ # from the path's shape. A local relative path like "app/models" (the
163+ # default above) is syntactically identical to a GitHub "org/repo"
164+ # string, so there's no reliable way to infer this from the string
165+ # alone; asking up front avoids the wizard silently misreading its own
166+ # suggested default as a repo.
167+ click .echo ()
168+ location_kind = click .prompt (
169+ f"3️⃣ Are your { location_noun } in this local project, or a different GitHub repo?" ,
170+ type = click .Choice (["local" , "github" ]),
171+ default = "local" ,
172+ show_default = True ,
173+ )
174+
175+ click .echo ()
176+ if location_kind == "github" :
177+ repo = click .prompt (
178+ "4️⃣ GitHub repo (org/repo)" , default = "" , show_default = False
179+ )
180+ while "/" not in repo or repo .count ("/" ) != 1 :
181+ click .echo (" ⚠️ Expected the form 'org/repo', e.g. 'my-org/my-api'" )
182+ repo = click .prompt ("4️⃣ GitHub repo (org/repo)" )
183+
184+ path = click .prompt (
185+ f" Path to your { location_noun } within { repo } (file or directory)" ,
186+ default = default_path ,
187+ show_default = True ,
186188 )
187- else :
188- is_github_repo = False
189-
190- if is_github_repo :
191- # Format: "org/repo" or "org/repo/path/to/models"
192- parts = api_location .split ("/" )
193- if len (parts ) >= 2 :
194- repo = "/" .join (parts [:2 ])
195- path = "/" .join (parts [2 :]) if len (parts ) > 2 else "app/models"
196- else :
197- repo = api_location
198- path = "app/models"
199189
200190 api_config = {"type" : "github" , "repo" : repo , "path" : path }
201- click .echo (f" 🐙 GitHub repo detected: { repo } /{ path } " )
202191
203192 token = os .environ .get ("GITHUB_TOKEN" )
204193 exists = _github_path_exists (repo , path , token )
@@ -214,9 +203,15 @@ def _interactive_setup() -> Dict[str, Any]:
214203 # exists is None -> couldn't verify (network issue); stay silent rather
215204 # than block setup on something that isn't actually wrong.
216205 else :
206+ api_location = click .prompt (
207+ f"4️⃣ Where are your { location_noun } ? (file or directory)" ,
208+ default = default_path ,
209+ show_default = True ,
210+ )
217211 api_config = {"type" : "local" , "path" : api_location }
218212
219213 # Check if local file/directory exists and provide feedback
214+ local_path = Path (api_location )
220215 if local_path .exists ():
221216 if local_path .is_file ():
222217 click .echo (f" ✅ Local file found: { api_location } " )
@@ -240,10 +235,10 @@ def _interactive_setup() -> Dict[str, Any]:
240235 if not click .confirm (" Continue anyway?" ):
241236 sys .exit (1 )
242237
243- # New question about manifest parsing
238+ # Question 5: manifest parsing
244239 click .echo ()
245240 disable_manifest = click .confirm (
246- "4️⃣ Disable manifest.json parsing? (recommended if you have CTE-based models)" ,
241+ "5️⃣ Disable manifest.json parsing? (recommended if you have CTE-based models)" ,
247242 default = True ,
248243 )
249244
0 commit comments