diff --git a/HISTORY.rst b/HISTORY.rst index a275d21b..68c2dd16 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,14 @@ Release History =============== +0.11.0 (2015-01-?) +------------------ + +* Added ``--json-output`` option to + `platformio boards `__ + command which allows to return the output in `JSON `_ format + (`issue #42 `_) + 0.10.2 (2015-01-06) ------------------- diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 77cbbb21..6e79a10c 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -10,7 +10,19 @@ from platformio.util import get_boards @click.command("list", short_help="Pre-configured Embedded Boards") @click.argument("query", required=False) -def cli(query): +@click.option("--json-output", is_flag=True) +def cli(query, json_output): + + if json_output: + result = {} + for type_, data in get_boards().items(): + if query: + search_data = "%s %s" % (type_, json.dumps(data).lower()) + if query.lower() not in search_data.lower(): + continue + result[type_] = data + click.echo(json.dumps(result)) + return BOARDLIST_TPL = ("{type:<30} {mcu:<13} {frequency:<8} " " {flash:<7} {ram:<6} {name}")