diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-04 13:34:17 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-04 14:59:05 -0400 |
commit | f2e4bc58f5b75c350609122654983a4e46c01326 (patch) | |
tree | d23e2de1308138b9b6b6109a629286e3a3063597 | |
parent | fe9a88a01347b729e0a928ea188f6cfc51f00d02 (diff) | |
download | buildstream-f2e4bc58f5b75c350609122654983a4e46c01326.tar.gz |
_frontend/main.py: Only prompt user when interactive
In both workspace_close() and workspace_reset() we do prompts,
but these need to also be usable without human interaction.
-rw-r--r-- | buildstream/_frontend/main.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index e2b2f8c2a..9fe7896a8 100644 --- a/buildstream/_frontend/main.py +++ b/buildstream/_frontend/main.py @@ -619,12 +619,12 @@ def workspace_open(app, no_checkout, force, source, variant, track, element, dir def workspace_close(app, source, remove_dir, variant, element): """Close a workspace""" - if remove_dir: + app.initialize(element, variant) + if app.interactive and remove_dir: if not click.confirm('This will remove all your changes, are you sure?'): click.echo('Aborting') sys.exit(-1) - app.initialize(element, variant) try: app.pipeline.close_workspace(source, remove_dir) click.echo("") @@ -646,14 +646,17 @@ def workspace_close(app, source, remove_dir, variant, element): help="Do not checkout the source, only link to the given directory") @click.option('--variant', help='A variant of the specified target') -@click.confirmation_option(prompt='This will remove all your changes, are you sure?') @click.argument('element', type=click.Path(dir_okay=False, readable=True)) @click.pass_obj def workspace_reset(app, source, track, no_checkout, variant, element): """Reset a workspace to its original state""" - app.initialize(element, variant) + if app.interactive: + if not click.confirm('This will remove all your changes, are you sure?'): + click.echo('Aborting') + sys.exit(-1) + try: app.pipeline.reset_workspace(app.scheduler, source, track, no_checkout) click.echo("") |