forked from platformio/platformio-core
Added --json-output
option to platformio search
command
This commit is contained in:
@ -15,7 +15,8 @@ Release History
|
|||||||
`#55 <https://github.com/ivankravets/platformio/issues/55>`_)
|
`#55 <https://github.com/ivankravets/platformio/issues/55>`_)
|
||||||
* Added ``--json-output`` option to
|
* Added ``--json-output`` option to
|
||||||
`platformio boards <http://docs.platformio.org/en/latest/userguide/cmd_boards.html>`__
|
`platformio boards <http://docs.platformio.org/en/latest/userguide/cmd_boards.html>`__
|
||||||
command which allows to return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
and `platformio search <http://docs.platformio.org/en/latest/userguide/cmd_search.html>`__
|
||||||
|
commands which allow to return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||||
(`issue #42 <https://github.com/ivankravets/platformio/issues/42>`_)
|
(`issue #42 <https://github.com/ivankravets/platformio/issues/42>`_)
|
||||||
* Allowed to ignore some libs from *Library Dependency Finder* via
|
* Allowed to ignore some libs from *Library Dependency Finder* via
|
||||||
`ignore_libs <http://docs.platformio.org/en/latest/projectconf.html#ignore-libs>`_ option
|
`ignore_libs <http://docs.platformio.org/en/latest/projectconf.html#ignore-libs>`_ option
|
||||||
|
@ -10,11 +10,7 @@ Usage
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# Print all available development platforms
|
platformio search QUERY [OPTIONS]
|
||||||
platformio search
|
|
||||||
|
|
||||||
# Filter platforms by "Query"
|
|
||||||
platformio search QUERY
|
|
||||||
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
@ -22,11 +18,33 @@ Description
|
|||||||
|
|
||||||
Search for development :ref:`Platforms <platforms>`
|
Search for development :ref:`Platforms <platforms>`
|
||||||
|
|
||||||
|
Options
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
.. option::
|
||||||
|
--json-output
|
||||||
|
|
||||||
|
Return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
1. Search for TI development platforms
|
1. Print all available development platforms
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ platformio search
|
||||||
|
atmelavr - An embedded platform for Atmel AVR microcontrollers (with Arduino Framework)
|
||||||
|
atmelsam - An embedded platform for Atmel SAM microcontrollers (with Arduino Framework)
|
||||||
|
digistump - An embedded platform for Digistump boards (with Arduino Framework)
|
||||||
|
stm32 - An embedded platform for STMicroelectronics ARM microcontrollers
|
||||||
|
teensy - An embedded platform for Teensy boards (with Arduino Framework)
|
||||||
|
timsp430 - An embedded platform for TI MSP430 microcontrollers (with Energia Framework)
|
||||||
|
titiva - An embedded platform for TI TIVA C ARM microcontrollers (with Energia and OpenCM3 Frameworks)
|
||||||
|
...
|
||||||
|
|
||||||
|
2. Search for TI development platforms
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
@ -34,9 +52,12 @@ Examples
|
|||||||
timsp430 - An embedded platform for TI MSP430 microcontrollers (with Energia Framework)
|
timsp430 - An embedded platform for TI MSP430 microcontrollers (with Energia Framework)
|
||||||
titiva - An embedded platform for TI TIVA C ARM microcontrollers (with Energia Framework)
|
titiva - An embedded platform for TI TIVA C ARM microcontrollers (with Energia Framework)
|
||||||
|
|
||||||
2. Search for development platforms which support "Arduino Framework"
|
3. Search for development platforms which support "Arduino Framework"
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ platformio search arduino
|
$ platformio search arduino
|
||||||
atmelavr - An embedded platform for Atmel AVR microcontrollers (with Arduino Framework)
|
atmelavr - An embedded platform for Atmel AVR microcontrollers (with Arduino Framework)
|
||||||
|
atmelsam - An embedded platform for Atmel SAM microcontrollers (with Arduino Framework)
|
||||||
|
digistump - An embedded platform for Digistump boards (with Arduino Framework)
|
||||||
|
teensy - An embedded platform for Teensy boards (with Arduino Framework)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||||
# See LICENSE for details.
|
# See LICENSE for details.
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from platformio.platforms.base import PlatformFactory
|
from platformio.platforms.base import PlatformFactory
|
||||||
@ -8,18 +10,32 @@ from platformio.platforms.base import PlatformFactory
|
|||||||
|
|
||||||
@click.command("search", short_help="Search for development platforms")
|
@click.command("search", short_help="Search for development platforms")
|
||||||
@click.argument("query", required=False)
|
@click.argument("query", required=False)
|
||||||
def cli(query):
|
@click.option("--json-output", is_flag=True)
|
||||||
for platform in PlatformFactory.get_platforms().keys():
|
def cli(query, json_output):
|
||||||
|
|
||||||
|
data = []
|
||||||
|
platforms = PlatformFactory.get_platforms().keys()
|
||||||
|
platforms.sort()
|
||||||
|
for platform in platforms:
|
||||||
p = PlatformFactory.newPlatform(platform)
|
p = PlatformFactory.newPlatform(platform)
|
||||||
name = p.get_name()
|
name = p.get_name()
|
||||||
shinfo = p.get_short_info()
|
info = p.get_short_info()
|
||||||
|
|
||||||
if query == "all":
|
if query == "all":
|
||||||
query = ""
|
query = ""
|
||||||
|
|
||||||
search_data = "%s %s" % (name, shinfo)
|
search_data = "%s %s" % (name, info)
|
||||||
if query and query.lower() not in search_data.lower():
|
if query and query.lower() not in search_data.lower():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
click.echo("{name:<20} - {info}".format(
|
data.append({
|
||||||
name=click.style(name, fg="cyan"), info=shinfo))
|
"name": name,
|
||||||
|
"info": info
|
||||||
|
})
|
||||||
|
|
||||||
|
if json_output:
|
||||||
|
click.echo(json.dumps(data))
|
||||||
|
else:
|
||||||
|
for item in data:
|
||||||
|
click.echo("{name:<20} - {info}".format(
|
||||||
|
name=click.style(item['name'], fg="cyan"), info=item['info']))
|
||||||
|
Reference in New Issue
Block a user