add config discovery
This commit is contained in:
parent
35ed79490a
commit
9106bc72fb
2 changed files with 16 additions and 3 deletions
1
src/zona/config.py
Normal file
1
src/zona/config.py
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue