mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Implement --json-output
and --page
options for pio lib search
command // Resolve #604
This commit is contained in:
@@ -9,6 +9,11 @@ PlatformIO 2.0
|
|||||||
|
|
||||||
* Project generator for `CodeBlocks IDE <http://docs.platformio.org/en/latest/ide/codeblocks.html>`__
|
* Project generator for `CodeBlocks IDE <http://docs.platformio.org/en/latest/ide/codeblocks.html>`__
|
||||||
(`issue #600 <https://github.com/platformio/platformio/issues/600>`_)
|
(`issue #600 <https://github.com/platformio/platformio/issues/600>`_)
|
||||||
|
* PlatformIO Library Registry in JSON format! Implemented
|
||||||
|
``--json-output`` and ``--page`` options for
|
||||||
|
`platformio lib search <http://docs.platformio.org/en/latest/userguide/lib/cmd_search.html>`__
|
||||||
|
command
|
||||||
|
(`issue #604 <https://github.com/platformio/platformio/issues/604>`_)
|
||||||
* Updated native SDK for ESP8266 to 1.5
|
* Updated native SDK for ESP8266 to 1.5
|
||||||
(`issue #366 <https://github.com/platformio/platformio/issues/366>`_)
|
(`issue #366 <https://github.com/platformio/platformio/issues/366>`_)
|
||||||
* Automatically reboot Teensy board after upload when Teensy Loader GUI is used
|
* Automatically reboot Teensy board after upload when Teensy Loader GUI is used
|
||||||
|
@@ -96,6 +96,17 @@ Filter libraries by specified framework
|
|||||||
|
|
||||||
Filter libraries by specified keyword
|
Filter libraries by specified keyword
|
||||||
|
|
||||||
|
.. option::
|
||||||
|
--json-output
|
||||||
|
|
||||||
|
Return the output in `JSON <http://en.wikipedia.org/wiki/JSON>`_ format
|
||||||
|
|
||||||
|
.. option::
|
||||||
|
--page
|
||||||
|
|
||||||
|
Manually paginate through search results. This option is useful in pair with
|
||||||
|
``--json-output``.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
VERSION = (2, 9, "0.dev0")
|
VERSION = (2, 9, "0.dev1")
|
||||||
__version__ = ".".join([str(s) for s in VERSION])
|
__version__ = ".".join([str(s) for s in VERSION])
|
||||||
|
|
||||||
__title__ = "platformio"
|
__title__ = "platformio"
|
||||||
|
@@ -56,12 +56,14 @@ def cli():
|
|||||||
|
|
||||||
|
|
||||||
@cli.command("search", short_help="Search for library")
|
@cli.command("search", short_help="Search for library")
|
||||||
|
@click.option("--json-output", is_flag=True)
|
||||||
|
@click.option("--page", type=click.INT, default=1)
|
||||||
@click.option("-a", "--author", multiple=True)
|
@click.option("-a", "--author", multiple=True)
|
||||||
@click.option("-k", "--keyword", multiple=True)
|
@click.option("-k", "--keyword", multiple=True)
|
||||||
@click.option("-f", "--framework", multiple=True)
|
@click.option("-f", "--framework", multiple=True)
|
||||||
@click.option("-p", "--platform", multiple=True)
|
@click.option("-p", "--platform", multiple=True)
|
||||||
@click.argument("query", required=False, nargs=-1)
|
@click.argument("query", required=False, nargs=-1)
|
||||||
def lib_search(query, **filters):
|
def lib_search(query, json_output, page, **filters):
|
||||||
if not query:
|
if not query:
|
||||||
query = []
|
query = []
|
||||||
if not isinstance(query, list):
|
if not isinstance(query, list):
|
||||||
@@ -71,7 +73,13 @@ def lib_search(query, **filters):
|
|||||||
for value in values:
|
for value in values:
|
||||||
query.append('%s:"%s"' % (key, value))
|
query.append('%s:"%s"' % (key, value))
|
||||||
|
|
||||||
result = get_api_result("/lib/search", dict(query=" ".join(query)))
|
result = get_api_result("/lib/search",
|
||||||
|
dict(query=" ".join(query), page=page))
|
||||||
|
|
||||||
|
if json_output:
|
||||||
|
click.echo(json.dumps(result))
|
||||||
|
return
|
||||||
|
|
||||||
if result['total'] == 0:
|
if result['total'] == 0:
|
||||||
click.secho(
|
click.secho(
|
||||||
"Nothing has been found by your request\n"
|
"Nothing has been found by your request\n"
|
||||||
@@ -103,7 +111,7 @@ def lib_search(query, **filters):
|
|||||||
click.confirm("Show next libraries?")):
|
click.confirm("Show next libraries?")):
|
||||||
result = get_api_result(
|
result = get_api_result(
|
||||||
"/lib/search",
|
"/lib/search",
|
||||||
dict(query=" ".join(query), page=str(int(result['page']) + 1))
|
dict(query=" ".join(query), page=int(result['page']) + 1)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user