mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Define a new "yunohost app search" command
This commit is contained in:
parent
4d494c7e7c
commit
6b04a4cae4
2 changed files with 24 additions and 0 deletions
|
@ -570,6 +570,13 @@ app:
|
||||||
help: Also return a list of app categories
|
help: Also return a list of app categories
|
||||||
action: store_true
|
action: store_true
|
||||||
|
|
||||||
|
### app_search()
|
||||||
|
search:
|
||||||
|
action_help: Search installable apps
|
||||||
|
arguments:
|
||||||
|
string:
|
||||||
|
help: Return matching app name or description with "string"
|
||||||
|
|
||||||
fetchlist:
|
fetchlist:
|
||||||
deprecated: true
|
deprecated: true
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,23 @@ def app_catalog(full=False, with_categories=False):
|
||||||
return {"apps": catalog["apps"], "categories": catalog["categories"]}
|
return {"apps": catalog["apps"], "categories": catalog["categories"]}
|
||||||
|
|
||||||
|
|
||||||
|
def app_search(string):
|
||||||
|
"""
|
||||||
|
Return a dict of apps whose description or name match the search string
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Retrieve a simple dict listing all apps
|
||||||
|
catalog_of_apps = app_catalog()
|
||||||
|
|
||||||
|
# Selecting apps according to a match in app name or description
|
||||||
|
for app in catalog_of_apps["apps"].items():
|
||||||
|
if not (re.search(string, app[0], flags=re.IGNORECASE) or
|
||||||
|
re.search(string, app[1]['description'], flags=re.IGNORECASE)):
|
||||||
|
del catalog_of_apps["apps"][app[0]]
|
||||||
|
|
||||||
|
return catalog_of_apps
|
||||||
|
|
||||||
|
|
||||||
# Old legacy function...
|
# Old legacy function...
|
||||||
def app_fetchlist():
|
def app_fetchlist():
|
||||||
logger.warning("'yunohost app fetchlist' is deprecated. Please use 'yunohost tools update --apps' instead")
|
logger.warning("'yunohost app fetchlist' is deprecated. Please use 'yunohost tools update --apps' instead")
|
||||||
|
|
Loading…
Add table
Reference in a new issue