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
|
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue