diff --git a/src/zona/config.py b/src/zona/config.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/zona/config.py @@ -0,0 +1 @@ + diff --git a/src/zona/layout.py b/src/zona/layout.py index 9bd8c92..5bfa71e 100644 --- a/src/zona/layout.py +++ b/src/zona/layout.py @@ -23,13 +23,25 @@ class 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( cli_root: Path | None = None, cli_output: Path | None = None ) -> Layout: if cli_root: root = cli_root else: - # TODO: config based discovery - # We just set cwd for now - root = Path(".") + config = find_config(cli_root) + if config: + root = config.parent + else: + root = Path.cwd() return Layout.from_input(root, cli_output)