packages: improve ux around cli and filter_pkgbuilds() to indicate that the query was empty or wrong
This commit is contained in:
parent
bca1e29648
commit
d3cdd64aea
2 changed files with 14 additions and 3 deletions
|
@ -83,6 +83,8 @@ def cmd_build(paths: list[str], force=False, arch: Optional[Arch] = None, rebuil
|
|||
@click.option('-B', '--no-build', is_flag=True, default=False, help="Don't try to build packages, just copy and install")
|
||||
def cmd_sideload(paths: Iterable[str], arch: Optional[Arch] = None, no_build: bool = False):
|
||||
"""Build packages, copy to the device via SSH and install them"""
|
||||
if not paths:
|
||||
raise Exception("No packages specified")
|
||||
arch = arch or get_profile_device(hint_or_set_arch=True).arch
|
||||
if not no_build:
|
||||
build(paths, False, arch=arch, try_download=True)
|
||||
|
@ -177,7 +179,7 @@ def cmd_check(paths):
|
|||
return True
|
||||
return False
|
||||
|
||||
paths = list(paths)
|
||||
paths = list(paths) or ['all']
|
||||
packages = filter_pkgbuilds(paths, allow_empty_results=False)
|
||||
|
||||
for package in packages:
|
||||
|
|
|
@ -388,8 +388,16 @@ def filter_pkgbuilds(
|
|||
) -> Iterable[Pkgbuild]:
|
||||
if not (use_names or use_paths):
|
||||
raise Exception('Error: filter_packages instructed to match neither by names nor paths; impossible!')
|
||||
paths = list(paths)
|
||||
plural = 's' if len(paths) > 1 else ''
|
||||
fields = []
|
||||
if use_names:
|
||||
fields.append('name' + plural)
|
||||
if use_paths:
|
||||
fields.append('path' + plural)
|
||||
fields_err = ' or '.join(fields)
|
||||
if not allow_empty_results and not paths:
|
||||
raise Exception("Can't search for packages: no query given")
|
||||
raise Exception(f"Can't search for packages: no {fields_err} given")
|
||||
repo = repo or discover_pkgbuilds()
|
||||
if 'all' in paths:
|
||||
all_pkgs = list(repo.values())
|
||||
|
@ -412,5 +420,6 @@ def filter_pkgbuilds(
|
|||
result += [pkg]
|
||||
|
||||
if not allow_empty_results and not result:
|
||||
raise Exception('No packages matched by paths: ' + ', '.join([f'"{p}"' for p in paths]))
|
||||
|
||||
raise Exception(f'No packages matched by {fields_err}: ' + ', '.join([f'"{p}"' for p in paths]))
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue