Skip to content
Snippets Groups Projects
Commit 4462d336 authored by Jonathan Maw's avatar Jonathan Maw
Browse files

cli.py: Add '--force' arg to workspace_close

--force will skip confirmation prompts, and removing the workspace
you're currently using to load the project will fail without "--force".
parent fbee452d
No related branches found
No related tags found
Loading
......@@ -733,10 +733,12 @@ def workspace_open(app, no_checkout, force, track_, element, directory):
help="Remove the path that contains the closed workspace")
@click.option('--all', '-a', 'all_', default=False, is_flag=True,
help="Close all open workspaces")
@click.option('--force', '-f', default=False, is_flag=True,
help="Always close the workspace and/or delete your changes")
@click.argument('elements', nargs=-1,
type=click.Path(readable=False))
@click.pass_obj
def workspace_close(app, remove_dir, all_, elements):
def workspace_close(app, remove_dir, all_, force, elements):
"""Close a workspace"""
if not (all_ or elements):
......@@ -767,10 +769,13 @@ def workspace_close(app, remove_dir, all_, elements):
if not click.confirm('Are you sure you want to close this workspace?'):
click.echo('Aborting', err=True)
sys.exit(-1)
elif not force:
raise AppError("Cannot close workspaces. Workspace {} is being used to load the project"
.format(element_name), reason='closing-required-workspace')
if nonexisting:
raise AppError("Workspace does not exist", detail="\n".join(nonexisting))
if app.interactive and remove_dir:
if app.interactive and remove_dir and not force:
if not click.confirm('This will remove all your changes, are you sure?'):
click.echo('Aborting', err=True)
sys.exit(-1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment