From 21e5e14ec94b7b17546ac94e73f1b770200e5704 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Mon, 4 Sep 2017 14:11:06 -0400 Subject: _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 --- buildstream/_frontend/main.py | 23 ++++++++++++++--------- 1 file 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 + }) ################################################################## -- cgit v1.2.1