Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,26 @@ With custom working directory:
prowler-studio feat/my_new_check -t check_ticket.md -w ./custom_work
```

Keep changes local (no push or PR creation):

```bash
prowler-studio -b feat/my-check --ticket check_ticket.md --local
```

> **Note**: You must provide either `--ticket` or `--jira-url`, not both.

### CLI Options

| Option | Short | Description |
|--------|-------|-------------|
| `--branch` | `-b` | Branch name (default: `feat/<ticket>-<check_name>` or `feat/<check_name>`) |
| `--ticket` | `-t` | Path to the markdown check ticket file |
| `--jira-url` | `-j` | Jira ticket URL (e.g., `https://mycompany.atlassian.net/browse/PROJ-123`) |
| `--working-dir` | `-w` | Path to the working directory (default: `./working`) |
| `--no-worktree` | | Legacy mode: work directly on main clone instead of using worktrees |
| `--cleanup-worktree` | | Remove worktree after successful PR creation |
| `--local` | | Keep changes local only (no push, no PR creation) |

## Project Structure

```
Expand Down
75 changes: 57 additions & 18 deletions src/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ def create_check(
help="Remove worktree after successful PR creation",
),
] = False,
local: Annotated[
bool,
typer.Option(
"--local",
help="Keep changes local only (no push, no PR creation)",
),
] = False,
) -> None:
"""
Create a Prowler check from a markdown ticket or Jira URL.
Expand All @@ -112,6 +119,12 @@ def create_check(
_console.print("[red]✗ Cannot provide both --ticket and --jira-url[/red]")
raise typer.Exit(code=1)

if local and cleanup_worktree:
_console.print(
"[red]✗ Cannot use --local with --cleanup-worktree (changes would be lost)[/red]"
)
raise typer.Exit(code=1)

# Validate file path if provided
if ticket_file:
ticket_file = ticket_file.resolve()
Expand Down Expand Up @@ -341,30 +354,56 @@ def create_check(

logging.info("[green]✓ Re-testing completed[/green]")

# Stage 6: PR Creation
logging.info("")
logging.info("=" * 60)
logging.info("STAGE: Stage 6: PR Creation")
logging.info("=" * 60)
pr_agent: PRCreationAgent = PRCreationAgent(
working_dir=prowler_repo_path,
check_name=impl_result.check_name,
check_provider=impl_result.check_provider,
branch_name=final_branch_name,
prowler_repo=repo,
jira_url=jira_url,
check_ticket=check_ticket_content,
)

pr_result: PRCreationResult = asyncio.run(pr_agent.run())
# Stage 6: PR Creation (unless --local)
pr_result: PRCreationResult | None = None
if not local:
logging.info("")
logging.info("=" * 60)
logging.info("STAGE: Stage 6: PR Creation")
logging.info("=" * 60)
pr_agent: PRCreationAgent = PRCreationAgent(
working_dir=prowler_repo_path,
check_name=impl_result.check_name,
check_provider=impl_result.check_provider,
branch_name=final_branch_name,
prowler_repo=repo,
jira_url=jira_url,
check_ticket=check_ticket_content,
)

pr_result = asyncio.run(pr_agent.run())
else:
logging.info("")
logging.info("=" * 60)
logging.info("STAGE: Stage 6: PR Creation (skipped - local mode)")
logging.info("=" * 60)
logging.info("[yellow]Local mode: skipping push and PR creation[/yellow]")

# Display final results
logging.info("")
logging.info("=" * 60)
logging.info("STAGE: Final Results")
logging.info("=" * 60)

if pr_result.success:
if local:
# Local mode: no push or PR creation
logging.info(
"[green]✓ Workflow completed successfully (local mode)![/green]"
)
logging.info(f" Check name: {impl_result.check_name}")
logging.info(f" Provider: {impl_result.check_provider}")
logging.info(f" Branch: {final_branch_name}")
logging.info(f" Working directory: {prowler_repo_path}")
logging.info("")
logging.info("[cyan]When ready to push and create PR:[/cyan]")
logging.info(f" cd {prowler_repo_path}")
logging.info(f" git push -u origin {final_branch_name}")
logging.info(" gh pr create")

logging.info("=" * 60)
logging.info("WORKFLOW COMPLETE")
logging.info("=" * 60)
elif pr_result and pr_result.success:
logging.info("[green]✓ Workflow completed successfully![/green]")
logging.info(f" Check name: {impl_result.check_name}")
logging.info(f" Provider: {impl_result.check_provider}")
Expand All @@ -386,7 +425,7 @@ def create_check(
logging.info(f" Check name: {impl_result.check_name}")
logging.info(f" Provider: {impl_result.check_provider}")
logging.info(f" Branch: {final_branch_name}")
if pr_result.error:
if pr_result and pr_result.error:
logging.info(f" PR Error: {pr_result.error}")
logging.info("[yellow]You can create the PR manually with:[/yellow]")
logging.info(f" cd {prowler_repo_path}")
Expand Down