From 53da11888eb6126cb01a51d374f24be78142847f Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 10 Jan 2021 03:17:20 +0000 Subject: minor tweaks to search filters && do not suggest --ebuild option when we have a match --- src/backend/searchbinary.py | 18 ++++++++---------- src/frontend/cli/README.md | 12 ++++++------ src/frontend/cli/sisyphus-cli.py | 18 +++++++++--------- 3 files changed, 23 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/backend/searchbinary.py b/src/backend/searchbinary.py index f4a65bd..b52c3c6 100644 --- a/src/backend/searchbinary.py +++ b/src/backend/searchbinary.py @@ -8,7 +8,7 @@ import sqlite3 def searchDB(filter, cat = '', pn = '', desc = ''): NOVIRT = "AND cat NOT LIKE 'virtual'" SELECTS = { - 'any': f'''SELECT + 'all': f'''SELECT i.category AS cat, i.name as pn, i.version as iv, @@ -60,7 +60,7 @@ def searchDB(filter, cat = '', pn = '', desc = ''): LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} AND av IS 'alien' ''', - 'remote': f'''SELECT + 'available': f'''SELECT a.category AS cat, a.name AS pn, i.version as iv, @@ -74,7 +74,7 @@ def searchDB(filter, cat = '', pn = '', desc = ''): LEFT JOIN remote_descriptions AS d ON a.name = d.name AND a.category = d.category WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} AND iv IS NULL''', - 'upgrade': f'''SELECT + 'upgradeable': f'''SELECT i.category AS cat, i.name AS pn, i.version as iv, @@ -102,11 +102,11 @@ def tosql(string): return '%%' if string == '' else string.replace('*', '%').replace('?', '_') def showSearch(filter, cat, pn, desc, single): - print(f"Looking into {filter} packages ...\n") + print(f"Searching {filter} packages ... \n") pkglist = searchDB(filter, tosql(cat), tosql(pn), tosql(desc)) if len(pkglist) == 0: - print("No binary package found!") + print("No package found!\nUse the '--ebuild' option to search for source packages!") else: if single: print(f"{'Package':45} {'Installed':20} Available") @@ -117,19 +117,17 @@ def showSearch(filter, cat, pn, desc, single): if pkg['av'] != 'alien': print(f"\tLatest available version: {pkg['av']}") else: - print(f"\tAlien package: Use `sisyphus search --ebuild {pkg['pn']}` for available version") + print(f"\tAlien package: Use `sisyphus search --ebuild {pkg['pn']}` for available version!") print(f"\tDescription: {pkg['desc']}\n") else: cpn = f"{pkg['cat']}/{pkg['pn']}" print(f"{cpn:45} {str(pkg['iv']):20} {str(pkg['av'])}") - print(f"\nFound {len(pkglist)} matching package(s)") - - print("To search for source packages, use the '--ebuild' option.") + print(f"\nFound {len(pkglist)} matching package(s) ...") def start(filter, cat, pn, desc, single): if sisyphus.check.root(): sisyphus.update.start() else: - print('\nYou are not root, cannot fetch updates.\nSearch result may be inaccurate!\n') + print("\nYou are not root, cannot fetch updates.\nSearch result may be inaccurate!\n") showSearch(filter, cat, pn, desc, single) diff --git a/src/frontend/cli/README.md b/src/frontend/cli/README.md index 0ef8b69..5636e2e 100644 --- a/src/frontend/cli/README.md +++ b/src/frontend/cli/README.md @@ -229,16 +229,16 @@ In addition, search can be performed by package description, using the -d (--des Use the -f (--filter) option to select only packages of interest. Possible values: - any (default) - search the entire database + all (default) - search the entire database alien - search for installed packages but not available (this filter can match packages installed from e-builds or packages no longer maintained as binaries) installed - search in all installed packages - remote - search for available packages but not installed + available - search for available packages but not installed - upgrade - search for installed packages where installed version is different from available version + upgradeable - search for installed packages where installed version is different from available version !!! NOTE !!!: @@ -249,9 +249,9 @@ To search for all matching '--filter' packages escape it, or surround it with qu sisyphus search \* -f alien # OK - sisyphus search '*' -f remote # OK + sisyphus search '*' -f available # OK - sisyphus search '' -f upgrade # OK + sisyphus search '' -f upgradeable # OK To search for all (including source) packages, use the --ebuild option. @@ -268,7 +268,7 @@ $ sisyphus search [OPTIONS] PACKAGE... **Options**: * `-d, --description TEXT`: Match description. -* `-f, --filter [any|alien|installed|remote|upgrade]`: [default: any] +* `-f, --filter [all|alien|installed|available|upgradeable]`: [default: all] * `-q`: Short (one line) output. * `-e, --ebuild`: Search in ebuilds (slower). * `--help`: Show this message and exit. diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index 8937c93..e69a547 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -21,16 +21,16 @@ def app_callback(ctx: typer.Context): ctx.info_name = 'sisyphus' class Filter(str, Enum): - any = 'any' + all = 'all' alien = 'alien' installed = 'installed' - remote = 'remote' - upgrade = 'upgrade' + available = 'available' + upgradeable = 'upgradeable' @app.command("search") def search(package: List[str] = typer.Argument(...), desc: str = typer.Option('', '--description', '-d', help = 'Match description.'), - filter: Filter = typer.Option(Filter.any, '--filter', '-f', show_default=True), + filter: Filter = typer.Option(Filter.all, '--filter', '-f', show_default=True), quiet: bool = typer.Option(False, '-q', help='Short (one line) output.'), ebuild: bool = typer.Option(False, "--ebuild", "-e", help = 'Search in ebuilds (slower).')): """Search for binary and/or ebuild (source) packages. @@ -62,16 +62,16 @@ def search(package: List[str] = typer.Argument(...), Use the -f (--filter) option to select only packages of interest. Possible values: - any (default) - search the entire database + all (default) - search the entire database alien - search for installed packages but not available (this filter can match packages installed from e-builds or packages no longer maintained as binaries) installed - search in all installed packages - remote - search for available packages but not installed + available - search for available packages but not installed - upgrade - search for installed packages where installed version is different from available version + upgradeable - search for installed packages where installed version is different from available version !!! NOTE !!!: @@ -82,9 +82,9 @@ def search(package: List[str] = typer.Argument(...), sisyphus search \* -f alien # OK - sisyphus search '*' -f remote # OK + sisyphus search '*' -f available # OK - sisyphus search '' -f upgrade # OK + sisyphus search '' -f upgradeable # OK To search for all (including source) packages, use the --ebuild option. -- cgit v1.2.3