diff --git a/cmd/flags/config.go b/cmd/flags/config.go index 41ed959..c3a0840 100644 --- a/cmd/flags/config.go +++ b/cmd/flags/config.go @@ -22,7 +22,7 @@ var ( UserAgent = client.DefaultUserAgent Proxy = "" ConfigRoot = "" - Keywords = "" + Keywords []string Retry = 3 SkipError = true @@ -71,16 +71,11 @@ func NewFetcher(category fetcher.Category, properties map[string]string) (fetche return nil, err } - keywords := strings.Split(Keywords, ",") - for i, keyword := range keywords { - keywords[i] = strings.TrimSpace(keyword) - } - return fetcher.New(&fetcher.Config{ Config: cc, Category: category, Formats: fs, - Keywords: keywords, + Keywords: Keywords, Extract: Extract, DownloadPath: DownloadPath, InitialBookID: InitialBookID, diff --git a/cmd/root.go b/cmd/root.go index 99be9c7..32edff4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -47,7 +47,8 @@ func init() { persistentFlags.StringVar(&flags.Proxy, "proxy", flags.Proxy, "The request proxy") persistentFlags.StringVarP(&flags.UserAgent, "user-agent", "a", flags.UserAgent, "The request user-agent") persistentFlags.IntVarP(&flags.Retry, "retry", "r", flags.Retry, "The retry times for a failed download") - persistentFlags.BoolVarP(&flags.SkipError, "skip-error", "s", flags.SkipError, "Continue to download the next book if the current book download failed") - persistentFlags.StringVarP(&flags.Keywords, "keywords", "k", flags.Keywords, "The keywords for books") + persistentFlags.BoolVarP(&flags.SkipError, "skip-error", "s", flags.SkipError, + "Continue to download the next book if the current book download failed") + persistentFlags.StringSliceVarP(&flags.Keywords, "keyword", "k", flags.Keywords, "The keywords for books") persistentFlags.BoolVar(&log.EnableDebug, "verbose", false, "Print all the logs for debugging") } diff --git a/cmd/sobooks.go b/cmd/sobooks.go index 23c35c6..9828f36 100644 --- a/cmd/sobooks.go +++ b/cmd/sobooks.go @@ -38,6 +38,7 @@ var sobooksCmd = &cobra.Command{ Row("Initial ID", flags.InitialBookID). Row("Rename File", flags.Rename). Row("Thread", flags.Thread). + Row("Keywords", flags.Keywords). Row("Thread Limit (req/min)", flags.RateLimit). Print() diff --git a/cmd/talebook.go b/cmd/talebook.go index cf692aa..bf46171 100644 --- a/cmd/talebook.go +++ b/cmd/talebook.go @@ -38,6 +38,7 @@ var talebookDownloadCmd = &cobra.Command{ Row("Initial ID", flags.InitialBookID). Row("Rename File", flags.Rename). Row("Thread", flags.Thread). + Row("Keywords", flags.Keywords). Row("Thread Limit (req/min)", flags.RateLimit). Print() diff --git a/cmd/telegram.go b/cmd/telegram.go index 2f1b07f..9eae7b8 100644 --- a/cmd/telegram.go +++ b/cmd/telegram.go @@ -37,6 +37,7 @@ var telegramCmd = &cobra.Command{ Row("Initial ID", flags.InitialBookID). Row("Rename File", flags.Rename). Row("Thread", flags.Thread). + Row("Keywords", flags.Keywords). Row("Thread Limit (req/min)", flags.RateLimit). Print()