From 102175215c934afa6eb31ade221e556aa658afa5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 24 Nov 2014 21:59:25 +0200 Subject: [PATCH] Allow for search args to be empty --- docs/userguide/cmd_search.rst | 2 +- docs/userguide/lib/cmd_search.rst | 9 ++++----- platformio/commands/lib.py | 5 ++++- platformio/commands/search.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/userguide/cmd_search.rst b/docs/userguide/cmd_search.rst index 7edd9568..a411c2e7 100644 --- a/docs/userguide/cmd_search.rst +++ b/docs/userguide/cmd_search.rst @@ -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 diff --git a/docs/userguide/lib/cmd_search.rst b/docs/userguide/lib/cmd_search.rst index 7bcf28b0..3156c0ee 100644 --- a/docs/userguide/lib/cmd_search.rst +++ b/docs/userguide/lib/cmd_search.rst @@ -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 `_. - 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 diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 60402ca9..40110320 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -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) diff --git a/platformio/commands/search.py b/platformio/commands/search.py index e798e587..ec814be4 100644 --- a/platformio/commands/search.py +++ b/platformio/commands/search.py @@ -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)