Skip to content

Commit 7342378

Browse files
fix: allow setting custom codebase path from codegen run (#672)
1 parent f1ff9e1 commit 7342378

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/codegen/cli/commands/run/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
@click.command(name="run")
1414
@requires_init
1515
@click.argument("label", required=True)
16+
@click.option("--path", type=str, help="Path to build the codebase from. Defaults to the repo root.")
1617
@click.option("--web", is_flag=True, help="Run the function on the web service instead of locally")
1718
@click.option("--diff-preview", type=int, help="Show a preview of the first N lines of the diff")
1819
@click.option("--arguments", type=str, help="Arguments as a json string to pass as the function's 'arguments' parameter")
1920
def run_command(
2021
session: CodegenSession,
2122
label: str,
23+
path: str | None = None,
2224
web: bool = False,
2325
diff_preview: int | None = None,
2426
arguments: str | None = None,
@@ -57,4 +59,4 @@ def run_command(
5759
else:
5860
from codegen.cli.commands.run.run_local import run_local
5961

60-
run_local(session, codemod, diff_preview=diff_preview)
62+
run_local(session, codemod, diff_preview=diff_preview, path=path)

src/codegen/cli/commands/run/run_local.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def run_local(
2626
session: CodegenSession,
2727
function: DecoratedFunction,
2828
diff_preview: int | None = None,
29+
path: Path | None = None,
2930
) -> None:
3031
"""Run a function locally against the codebase.
3132
@@ -35,10 +36,10 @@ def run_local(
3536
diff_preview: Number of lines of diff to preview (None for all)
3637
"""
3738
# Parse codebase and run
38-
repo_root = session.repo_path
39+
codebase_path = f"{session.repo_path}/{path}" if path else session.repo_path
3940

40-
with Status(f"[bold]Parsing codebase at {repo_root} ...", spinner="dots") as status:
41-
codebase = parse_codebase(repo_root)
41+
with Status(f"[bold]Parsing codebase at {codebase_path} ...", spinner="dots") as status:
42+
codebase = parse_codebase(codebase_path)
4243
status.update("[bold green]✓ Parsed codebase")
4344

4445
status.update("[bold]Running codemod...")

0 commit comments

Comments
 (0)