summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 14:11:06 -0400
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 14:59:05 -0400
commit21e5e14ec94b7b17546ac94e73f1b770200e5704 (patch)
treeefb356cdc7fd69139b1ff000bbe48d08c2cee21f
parentf2e4bc58f5b75c350609122654983a4e46c01326 (diff)
downloadbuildstream-21e5e14ec94b7b17546ac94e73f1b770200e5704.tar.gz
_frontend/main.py: `bst workspace list` in machine readable format.
It's important to be able to programatically interact with buildstream for things, that includes managing workspaces. This commit just dumps some serialized yaml instead of doing the pretty printing. This closes issue #55
-rw-r--r--buildstream/_frontend/main.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index 9fe7896a8..921cbf365 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -682,15 +682,20 @@ def workspace_list(app):
click.echo("Error loading project: %s" % str(e))
sys.exit(1)
- logger = LogLine(app.content_profile,
- app.format_profile,
- app.success_profile,
- app.error_profile,
- app.detail_profile,
- indent=4)
-
- report = logger.show_workspaces(project._workspaces())
- click.echo(report, color=app.colors)
+ workspaces = []
+ for element_name, source_index, directory in project._workspaces():
+ workspace = {
+ 'element': element_name,
+ 'directory': directory,
+ }
+ if source_index > 0:
+ workspace['index'] = source_index
+
+ workspaces.append(workspace)
+
+ _yaml.dump({
+ 'workspaces': workspaces
+ })
##################################################################