diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-04 14:11:06 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-04 14:59:05 -0400 |
commit | 21e5e14ec94b7b17546ac94e73f1b770200e5704 (patch) | |
tree | efb356cdc7fd69139b1ff000bbe48d08c2cee21f | |
parent | f2e4bc58f5b75c350609122654983a4e46c01326 (diff) | |
download | buildstream-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.py | 23 |
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 + }) ################################################################## |