add config discovery

This commit is contained in:
Daniel Fichtinger 2025-06-22 15:11:15 -04:00
parent 35ed79490a
commit 9106bc72fb
2 changed files with 16 additions and 3 deletions

1
src/zona/config.py Normal file
View file

@ -0,0 +1 @@

View file

@ -23,13 +23,25 @@ class Layout:
return layout return layout
def find_config(start: Path | None = None) -> Path | None:
current = (start or Path.cwd()).resolve()
for parent in [current, *current.parents]:
candidate = parent / "zona.yml"
if candidate.is_file():
return candidate
return None
def discover_layout( def discover_layout(
cli_root: Path | None = None, cli_output: Path | None = None cli_root: Path | None = None, cli_output: Path | None = None
) -> Layout: ) -> Layout:
if cli_root: if cli_root:
root = cli_root root = cli_root
else: else:
# TODO: config based discovery config = find_config(cli_root)
# We just set cwd for now if config:
root = Path(".") root = config.parent
else:
root = Path.cwd()
return Layout.from_input(root, cli_output) return Layout.from_input(root, cli_output)