Skip to content

Commit

Permalink
feat: add option to build single module
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-ni committed Sep 12, 2023
1 parent 26efda2 commit 6711c6d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions transpire/internal/cli/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ def commands(**_) -> None:

@commands.command()
@click.argument("out_path", envvar="TRANSPIRE_OBJECT_OUTPUT", type=click.Path())
def build(out_path, **_) -> None:
@click.option("--module")
def build(out_path, module, **_) -> None:
"""build objects, write them to a folder"""
config = ClusterConfig.from_cwd()
modules = [
c.load_module_w_context(n, context=config) for n, c in config.modules.items()
]

if module is None:
modules = [
c.load_module_w_context(n, context=config)
for n, c in config.modules.items()
]
else:
modules = [config.modules[module].load_module_w_context(module, context=config)]

out_path = Path(out_path)
out_path.mkdir(exist_ok=True, parents=True)
Expand All @@ -36,7 +42,7 @@ def build(out_path, **_) -> None:

logger.info("Writing bases")
basedir = Path(out_path) / "base"
if basedir.exists():
if basedir.exists() and module is not None:
rmtree(basedir)
for module in modules:
render.write_base(basedir, module)
Expand Down

0 comments on commit 6711c6d

Please sign in to comment.