Allow for search args to be empty

This commit is contained in:
Ivan Kravets
2014-11-24 21:59:25 +02:00
parent cd2cc16fcf
commit 102175215c
4 changed files with 10 additions and 8 deletions

View File

@ -11,7 +11,7 @@ Usage
.. code-block:: bash
# Print all available development platforms
platformio search all
platformio search
# Filter platforms by "Query"
platformio search QUERY

View File

@ -90,7 +90,7 @@ Examples
.. code-block:: bash
$ platformio lib search ""
$ platformio lib search
# Found N libraries:
#
# [ ID ] Name Compatibility "Authors": Description
@ -112,7 +112,7 @@ Examples
.. code-block:: bash
$ platformio lib search "1-wire"
$ platformio lib search "1-wire"
# Found N libraries:
#
# [ ID ] Name Compatibility "Authors": Description
@ -136,11 +136,10 @@ Examples
# ...
4. Search for `libraries by "web" and "http" keywords <http://platformio.ikravets.com/#!/lib/search?query=keyword%253A%2522web%2522%2520keyword%253A%2522http%2522&page=1>`_.
The ``""`` here is for "empty" query argument
.. code-block:: bash
$ platformio lib search "" --keyword="web" --keyword="http"
$ platformio lib search --keyword="web" --keyword="http"
# Found N libraries:
#
# [ ID ] Name Compatibility "Authors": Description
@ -153,7 +152,7 @@ Examples
.. code-block:: bash
$ platformio lib search "" --author="Adafruit Industries"
$ platformio lib search --author="Adafruit Industries"
# Found N libraries:
#
# [ ID ] Name Compatibility "Authors": Description

View File

@ -46,8 +46,11 @@ def cli():
@click.option("-k", "--keyword", multiple=True)
@click.option("-f", "--framework", multiple=True)
@click.option("-p", "--platform", multiple=True)
@click.argument("query")
@click.argument("query", required=False)
def lib_search(query, **filters):
if not query:
query = ""
for key, values in filters.iteritems():
for value in values:
query += ' %s:"%s"' % (key, value)

View File

@ -7,7 +7,7 @@ from platformio.platforms.base import PlatformFactory
@command("search", short_help="Search for development platforms")
@argument("query")
@argument("query", required=False)
def cli(query):
for platform in PlatformFactory.get_platforms().keys():
p = PlatformFactory().newPlatform(platform)