mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Add "--json-output" option to "platformio list", "platformio serialports list" and "platformio lib list" cmds // Resolve #42
This commit is contained in:
14
HISTORY.rst
14
HISTORY.rst
@ -4,11 +4,19 @@ Release History
|
||||
0.10.1 (?)
|
||||
----------
|
||||
|
||||
* Fixed missing auto-uploading by default within `platformio init <http://docs.platformio.org/en/latest/userguide/cmd_init.html>`__
|
||||
* Added ``--json-output`` option to
|
||||
`platformio list <http://docs.platformio.org/en/latest/userguide/cmd_list.html>`__,
|
||||
`platformio serialports list <http://docs.platformio.org/en/latest/userguide/cmd_serialports.html>`__ and
|
||||
`platformio lib list <http://docs.platformio.org/en/latest/userguide/cmd_lib_list.html>`__
|
||||
commands which allows to return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||
(`issue #42 <https://github.com/ivankravets/platformio/issues/42>`_)
|
||||
* Fixed missing auto-uploading by default after `platformio init <http://docs.platformio.org/en/latest/userguide/cmd_init.html>`__
|
||||
command
|
||||
|
||||
0.10.0 (2015-01-01) Happy New Year!
|
||||
-----------------------------------
|
||||
0.10.0 (2015-01-01)
|
||||
-------------------
|
||||
|
||||
**Happy New Year!**
|
||||
|
||||
* Implemented `platformio boards <http://docs.platformio.org/en/latest/userguide/cmd_boards.html>`_
|
||||
command (`issue #11 <https://github.com/ivankravets/platformio/issues/11>`_)
|
||||
|
@ -9,7 +9,8 @@ Quickstart
|
||||
|
||||
1. :ref:`Install PlatformIO <installation>`.
|
||||
|
||||
2. Find board ``type`` from :ref:`platforms` or via :ref:`cmd_boards` command.
|
||||
2. Find board ``type`` on this :ref:`Embedded Boards <platforms>` page or
|
||||
via :ref:`cmd_boards` command.
|
||||
|
||||
3. Initialize new PlatformIO based project with the pre-configured
|
||||
environments for your boards:
|
||||
|
@ -10,7 +10,7 @@ Usage
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
platformio list
|
||||
platformio list [OPTIONS]
|
||||
|
||||
|
||||
Description
|
||||
@ -18,6 +18,13 @@ Description
|
||||
|
||||
List installed :ref:`Platforms <platforms>`
|
||||
|
||||
Options
|
||||
~~~~~~~
|
||||
|
||||
.. option::
|
||||
--json-output
|
||||
|
||||
Return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
@ -13,7 +13,7 @@ Usage
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
platformio serialports list
|
||||
platformio serialports list [OPTIONS]
|
||||
|
||||
|
||||
Description
|
||||
@ -21,6 +21,14 @@ Description
|
||||
|
||||
List available `Serial Ports <http://en.wikipedia.org/wiki/Serial_port>`_
|
||||
|
||||
Options
|
||||
~~~~~~~
|
||||
|
||||
.. option::
|
||||
--json-output
|
||||
|
||||
Return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||
|
||||
|
||||
Examples
|
||||
~~~~~~~~
|
||||
|
@ -10,7 +10,7 @@ Usage
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
platformio lib list
|
||||
platformio lib list [OPTIONS]
|
||||
|
||||
|
||||
Description
|
||||
@ -18,6 +18,13 @@ Description
|
||||
|
||||
List installed libraries
|
||||
|
||||
Options
|
||||
~~~~~~~
|
||||
|
||||
.. option::
|
||||
--json-output
|
||||
|
||||
Return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
@ -17,7 +17,7 @@ from platformio.util import get_boards, get_source_dir
|
||||
type=click.Path(exists=True, file_okay=False, dir_okay=True,
|
||||
writable=True, resolve_path=True))
|
||||
@click.option("--board", "-b", multiple=True, metavar="TYPE")
|
||||
@click.option('--disable-auto-uploading', is_flag=True)
|
||||
@click.option("--disable-auto-uploading", is_flag=True)
|
||||
def cli(project_dir, board, disable_auto_uploading):
|
||||
|
||||
project_file = join(project_dir, "platformio.ini")
|
||||
|
@ -154,9 +154,15 @@ def lib_uninstall(libid):
|
||||
|
||||
|
||||
@cli.command("list", short_help="List installed libraries")
|
||||
def lib_list():
|
||||
@click.option("--json-output", is_flag=True)
|
||||
def lib_list(json_output):
|
||||
lm = LibraryManager(get_lib_dir())
|
||||
items = lm.get_installed().values()
|
||||
|
||||
if json_output:
|
||||
click.echo(items)
|
||||
return
|
||||
|
||||
if not items:
|
||||
return
|
||||
|
||||
|
@ -7,15 +7,26 @@ from platformio.platforms.base import PlatformFactory
|
||||
|
||||
|
||||
@click.command("list", short_help="List installed platforms")
|
||||
def cli():
|
||||
@click.option("--json-output", is_flag=True)
|
||||
def cli(json_output):
|
||||
|
||||
installed_platforms = PlatformFactory.get_platforms(
|
||||
installed=True).keys()
|
||||
installed_platforms.sort()
|
||||
|
||||
data = []
|
||||
for platform in installed_platforms:
|
||||
p = PlatformFactory.newPlatform(platform)
|
||||
click.echo("{name:<20} with packages: {pkgs}".format(
|
||||
name=click.style(p.get_name(), fg="cyan"),
|
||||
pkgs=", ".join(p.get_installed_packages())
|
||||
))
|
||||
data.append({
|
||||
"name": platform,
|
||||
"packages": p.get_installed_packages()
|
||||
})
|
||||
|
||||
if json_output:
|
||||
click.echo(data)
|
||||
else:
|
||||
for item in data:
|
||||
click.echo("{name:<20} with packages: {pkgs}".format(
|
||||
name=click.style(item['name'], fg="cyan"),
|
||||
pkgs=", ".join(item['packages'])
|
||||
))
|
||||
|
@ -15,7 +15,12 @@ def cli():
|
||||
|
||||
|
||||
@cli.command("list", short_help="List Serial ports")
|
||||
def serialports_list():
|
||||
@click.option("--json-output", is_flag=True)
|
||||
def serialports_list(json_output):
|
||||
|
||||
if json_output:
|
||||
click.echo(get_serialports())
|
||||
return
|
||||
|
||||
for item in get_serialports():
|
||||
click.secho(item['port'], fg="cyan")
|
||||
|
Reference in New Issue
Block a user