Skip to content

Commit 3cf6cf5

Browse files
gnzjgoampcode-com
andcommitted
Read folder from tinybird.config.json when user picks it interactively
When the user doesn't pass --folder but types a folder name in the tinybird CLI interactive prompt, read the include path from the generated tinybird.config.json to place SDK files in the right folder. Amp-Thread-ID: https://ampcode.com/threads/T-019d1a2d-e5a7-77fb-b97e-e855f84a34a4 Co-authored-by: Amp <amp@ampcode.com>
1 parent 475fd8b commit 3cf6cf5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • src/tinybird_sdk/cli/commands

src/tinybird_sdk/cli/commands/init.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,24 @@ def run_init(options: InitOptions | dict[str, Any] | None = None) -> InitResult:
175175
cli_argv.extend(["--folder", normalized.folder])
176176
_run_tinybird_cli_init(cli_argv)
177177

178-
# 2. Create Python SDK template files on top
178+
# 2. Determine the target folder for SDK template files
179+
# Priority: --folder flag > folder from tinybird.config.json > default
180+
folder: Path | None = None
179181
if normalized.folder:
180182
folder = Path(normalized.folder)
181183
if not folder.is_absolute():
182184
folder = cwd / folder
183185
else:
186+
# Read the folder the tinybird CLI configured (from the interactive prompt)
187+
config_path_check = find_existing_config_path(str(cwd))
188+
if config_path_check and config_path_check.endswith(".json"):
189+
with open(config_path_check, "r", encoding="utf-8") as fp:
190+
cli_config = json.load(fp)
191+
include = cli_config.get("include", [])
192+
if include:
193+
folder = cwd / Path(include[0])
194+
195+
if folder is None:
184196
src = cwd / "src"
185197
folder = (src / "lib") if src.is_dir() else (cwd / "lib")
186198

0 commit comments

Comments
 (0)