From c3e6e9344688902f541389582a8016b8e966e5ef Mon Sep 17 00:00:00 2001 From: Luke Browning <24992944+browningluke@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:18:37 -0800 Subject: [PATCH] Display warning when no manga are found (#113) --- cmd/mangathr/download/download.go | 7 +++++++ cmd/mangathr/register/run.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/cmd/mangathr/download/download.go b/cmd/mangathr/download/download.go index a981f62..debff6a 100644 --- a/cmd/mangathr/download/download.go +++ b/cmd/mangathr/download/download.go @@ -54,6 +54,13 @@ func (o *downloadOpts) run(cfg *config.Config) { // Search and select manga titles, err := scraper.Search(o.Query) + + // Exit if no manga are found + if len(titles) == 0 { + ui.PrintlnColor(ui.Yellow, "No manga found with specified query. Exiting...") + return + } + logging.ExitIfError(err) selection, uierr := ui.SingleCheckboxes("Select Manga:", titles) diff --git a/cmd/mangathr/register/run.go b/cmd/mangathr/register/run.go index a1a3ce5..b21ace6 100644 --- a/cmd/mangathr/register/run.go +++ b/cmd/mangathr/register/run.go @@ -70,6 +70,12 @@ func findManga(args *registerOpts) (options, bool) { return options{}, true } + // Exit if no manga are found + if len(titles) == 0 { + ui.PrintlnColor(ui.Yellow, "No manga found with specified query. Exiting...") + return options{}, true + } + selection := titles[0] if len(titles) > 1 { var uierr error