Skip to content

Commit 5b3e9e2

Browse files
authored
Add possibility to abort (#244)
1 parent 69d1cb9 commit 5b3e9e2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

openhexa/cli/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def select_pipeline(workspace_pipelines, number_of_pages: int, pipeline):
265265
"""Select a pipeline from the list of workspace pipelines or select creating a new one or select a pipeline from a code."""
266266
create_new_pipeline = f"Create a new {click.style(pipeline.name, bold=True)} pipeline"
267267
enter_pipeline_code = f"Insert a {click.style('pipeline code', italic=True)}"
268+
cancel = "Cancel"
268269

269270
def _generate_choices():
270271
"""Generate the list of choices for the user."""
@@ -275,6 +276,7 @@ def _generate_choices():
275276
]
276277
+ [create_new_pipeline]
277278
+ ([enter_pipeline_code] if number_of_pages > 1 else [])
279+
+ [cancel]
278280
)
279281

280282
def _handle_user_selection(choices):
@@ -296,6 +298,8 @@ def _handle_user_selection(choices):
296298
return None
297299
elif choices[choice_idx] == enter_pipeline_code:
298300
return _handle_enter_pipeline_code()
301+
elif choices[choice_idx] == cancel:
302+
raise click.Abort()
299303
else:
300304
return workspace_pipelines[choice_idx]
301305

0 commit comments

Comments
 (0)