CLI: Save installed AddOns state more often to enable better error recovery. Sort list output alphabetically.
This commit is contained in:
parent
bedea2f983
commit
d08e0bebcc
27
wau/cli.py
27
wau/cli.py
|
@ -98,7 +98,7 @@ class CLI:
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
||||||
def install(self, args) -> None:
|
def install(self, args) -> None:
|
||||||
already_installed_urls = {a.url for a in self.installed_addons}
|
already_installed_urls = {addon.url for addon in self.installed_addons}
|
||||||
for url in set(args.urls): # set removes duplicates
|
for url in set(args.urls): # set removes duplicates
|
||||||
if url in already_installed_urls:
|
if url in already_installed_urls:
|
||||||
print(f"{url} is already installed")
|
print(f"{url} is already installed")
|
||||||
|
@ -108,21 +108,16 @@ class CLI:
|
||||||
addon.download()
|
addon.download()
|
||||||
addon.install()
|
addon.install()
|
||||||
self.installed_addons.append(addon)
|
self.installed_addons.append(addon)
|
||||||
addons.save_installed_addons(self.installed_addons)
|
addons.save_installed_addons(self.installed_addons)
|
||||||
|
|
||||||
def remove(self, args) -> None:
|
def remove(self, args) -> None:
|
||||||
if args.all:
|
for addon in self.installed_addons:
|
||||||
remove = self.installed_addons.copy()
|
if args.all or addon.name in args.addons:
|
||||||
else:
|
print(f"Removing {addon.name}")
|
||||||
remove = [addon
|
addon.uninstall()
|
||||||
for addon in self.installed_addons
|
shutil.rmtree(addon.download_dir, ignore_errors=True)
|
||||||
if addon.name in args.addons]
|
self.installed_addons.remove(addon)
|
||||||
for addon in remove:
|
addons.save_installed_addons(self.installed_addons)
|
||||||
print(f"Removing {addon.name}")
|
|
||||||
addon.uninstall()
|
|
||||||
shutil.rmtree(addon.download_dir, ignore_errors=True)
|
|
||||||
self.installed_addons.remove(addon)
|
|
||||||
addons.save_installed_addons(self.installed_addons)
|
|
||||||
|
|
||||||
def update(self, args) -> None:
|
def update(self, args) -> None:
|
||||||
for addon in self.installed_addons:
|
for addon in self.installed_addons:
|
||||||
|
@ -132,11 +127,11 @@ class CLI:
|
||||||
addon.uninstall()
|
addon.uninstall()
|
||||||
addon.install()
|
addon.install()
|
||||||
print("Done" if changed else "Already up to date")
|
print("Done" if changed else "Already up to date")
|
||||||
addons.save_installed_addons(self.installed_addons)
|
addons.save_installed_addons(self.installed_addons)
|
||||||
|
|
||||||
def list(self, args) -> None:
|
def list(self, args) -> None:
|
||||||
table = []
|
table = []
|
||||||
for addon in self.installed_addons:
|
for addon in sorted(self.installed_addons, key=lambda a: a.name.lower()):
|
||||||
table.append({
|
table.append({
|
||||||
"Name": addon.name,
|
"Name": addon.name,
|
||||||
"Provider": addon.get_provider().__name__,
|
"Provider": addon.get_provider().__name__,
|
||||||
|
|
Loading…
Reference in a new issue