Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Commit

Permalink
Added multiple selections to removing shows
Browse files Browse the repository at this point in the history
  • Loading branch information
PraneethJain committed Jun 16, 2022
1 parent b31917f commit 79fc61d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions ardor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ def add(query: str):
def remove(all: bool = False):
manager = Manager()
manager.load_shows_watching()
index, _ = selection_menu(manager.shows_watching)
print(manager.remove_show(index))
indices, _ = selection_menu_mutiple(manager.shows_watching)
for output in manager.remove_show(indices):
print(output)


@cli.command()
Expand Down
8 changes: 5 additions & 3 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ def add_show(self, show: str):
json.dump(self.shows_watching, f)
return f"[green bold]Added {show}[/green bold]"

def remove_show(self, i):
removed_show = self.shows_watching.pop(i)
def remove_show(self, indices):
for i in sorted(indices, reverse=True):
removed_show = self.shows_watching[i]
yield f"[magenta]Removed [bold]{removed_show}[/bold][/magenta]"
del self.shows_watching[i]
with open(resource_path("data/shows_watching.json"), "w") as f:
json.dump(self.shows_watching, f)
return f"[magenta]Removed [bold]{removed_show}[/bold][/magenta]"

def watching_shows(self):
table = Table(title="Shows Watching")
Expand Down

0 comments on commit 79fc61d

Please sign in to comment.