Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SirEntropy committed Dec 13, 2024
1 parent 9d42cc4 commit f2d8698
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cased/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ def cli():


if __name__ == "__main__":
cli()
try:
cli()
except Exception as _:
click.echo("\nProcess interrupted. Exiting.")
9 changes: 6 additions & 3 deletions cased/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def _build_questionary_choices(project):
project_name=project,
)
branches = data.get("pull_requests", [])
print(branches)
deployable_branches = [
branch for branch in branches if branch["deployable"] is True
]
Expand All @@ -39,6 +38,10 @@ def _build_questionary_choices(project):

selected = questionary.select("Select a branch to deploy:", choices=choices).ask()

if not selected:
console.print("[red]Error: No branch selected.[/red]")
sys.exit(1)

branch = selected.split(" -> ")[0]

# Find the selected branch in our data
Expand All @@ -47,12 +50,12 @@ def _build_questionary_choices(project):
)
if not selected_branch:
console.print(f"[red]Error: Branch {branch} is not deployable.[/red]")
return
sys.exit(1)

available_targets = selected_branch["targets"]
if not available_targets:
console.print(f"[red]Error: No targets available for branch {branch}.[/red]")
return
sys.exit(1)
target = questionary.select(
"Select a target environment:", choices=available_targets
).ask()
Expand Down

0 comments on commit f2d8698

Please sign in to comment.