summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2018-04-09 23:11:41 +0100
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-04-17 13:01:22 +0000
commitb264430d16e1e8978bbdf314a8bc4ac18df02cf1 (patch)
tree6d806d02d2b06156326684de24bc4ce6afee0d3d /buildstream
parent6c23e337abf702dbb34a56ca17cc7d09857a8ccc (diff)
downloadbuildstream-b264430d16e1e8978bbdf314a8bc4ac18df02cf1.tar.gz
_frontend/cli.py: Add option to reset multiple workspaces
!357 added support for closing multiple workspaces. Similarly, also allow `bst workspace reset` to work on multiple workspaces, with `--all` as a helper to reset all open workspaces.
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_frontend/cli.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 628a6cc85..3d50d5c14 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -660,20 +660,30 @@ def workspace_close(app, remove_dir, all_, elements):
@workspace.command(name='reset', short_help="Reset a workspace to its original state")
@click.option('--track', 'track_', default=False, is_flag=True,
help="Track and fetch the latest source before resetting")
-@click.argument('element',
+@click.option('--all', '-a', 'all_', default=False, is_flag=True,
+ help="Reset all open workspaces")
+@click.argument('elements', nargs=-1,
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
-def workspace_reset(app, track_, element):
+def workspace_reset(app, track_, all_, elements):
"""Reset a workspace to its original state"""
+
+ if not (all_ or elements):
+ click.echo('ERROR: no elements specified', err=True)
+ sys.exit(-1)
+
if app.interactive:
if not click.confirm('This will remove all your changes, are you sure?'):
click.echo('Aborting', err=True)
sys.exit(-1)
- with app.initialized((element,)):
- # This command supports only one target
- target = app.pipeline.targets[0]
- app.reset_workspace(target, track_)
+ with app.partially_initialized():
+ if all_:
+ elements = tuple(element_name for element_name, _ in app.project.workspaces.list())
+
+ with app.initialized(elements):
+ for target in app.pipeline.targets:
+ app.reset_workspace(target, track_)
##################################################################