Commit 3e9a8b59 authored by Seblu's avatar Seblu

Add a switch to auto select all matching packages

parent 3f17472b
......@@ -272,11 +272,14 @@ def list_packages(packages, long=False):
for package in packages:
print(pattern % package)
def select_packages(packages):
def select_packages(packages, select_all=False):
"""select a package in a list"""
# shortcut to one package
if len(packages) == 1:
yield packages[0]
elif select_all:
for pkg in packages:
yield pkg
else:
# display a list of packages to select
index = dict(enumerate(packages))
......@@ -301,14 +304,14 @@ def select_packages(packages):
else:
warn("No package n°%s" % num)
def get_packages(packages):
def get_packages(packages, select_all=False):
"""download packages"""
for pkg in select_packages(packages):
for pkg in select_packages(packages, select_all):
pkg.get()
def install_packages(packages):
def install_packages(packages, select_all=False):
"""install packages in one shot to allow deps to work"""
packages = list(select_packages(packages))
packages = list(select_packages(packages, select_all))
with TemporaryDirectory() as tmpdir:
cwd = getcwd()
chdir(tmpdir)
......@@ -338,6 +341,8 @@ def parse_argv():
g_action.add_argument("-i", "--install", action="store_const", dest="mode",
const="install", help="install matching packages")
# common options
p_main.add_argument("-a", "--all", action="store_true",
help="select all packages without prompting")
p_main.add_argument("-A", "--arch", nargs="*", default=[local_arch, "any"],
help="filter by architectures (default: %s and any. empty means all)" % local_arch)
p_main.add_argument("-v", "--verbose", action="store_true",
......@@ -377,9 +382,9 @@ def main():
if args.mode == "list":
list_packages(packages, long=args.verbose)
elif args.mode == "install":
install_packages(packages)
install_packages(packages, args.all)
else:
get_packages(packages)
get_packages(packages, args.all)
except KeyboardInterrupt:
exit(Error.ERR_ABORT)
except Error as exp:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment