Skip to content

Commit

Permalink
fix(torrent): remove with only filter (#82)
Browse files Browse the repository at this point in the history
* Add short cmdline options for filter and include-category

* Also remove torrents if only filter was set

* Update README to reflect new goreleaser cmdline interface
  • Loading branch information
jmechnich authored Apr 5, 2024
1 parent 7295702 commit d029c02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Or with only go

Builds with `goreleaser` will also include version info.

goreleaser release --snapshot --skip-publish --clean
goreleaser release --snapshot --skip=publish --clean

## Configuration

Expand Down
7 changes: 5 additions & 2 deletions cmd/torrent_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func RunTorrentRemove() *cobra.Command {
command.Flags().BoolVar(&dryRun, "dry-run", false, "Display what would be done without actually doing it")
command.Flags().BoolVar(&removeAll, "all", false, "Removes all torrents")
command.Flags().BoolVar(&deleteFiles, "delete-files", false, "Also delete downloaded files from torrent(s)")
command.Flags().StringVar(&filter, "filter", "", "Filter by state: all, active, paused, completed, stalled, errored")
command.Flags().StringVarP(&filter, "filter", "f", "", "Filter by state: all, active, paused, completed, stalled, errored")
command.Flags().StringSliceVar(&hashes, "hashes", []string{}, "Add hashes as comma separated list")
command.Flags().StringSliceVar(&includeCategory, "include-category", []string{}, "Remove torrents from these categories. Comma separated")
command.Flags().StringSliceVarP(&includeCategory, "include-category", "c", []string{}, "Remove torrents from these categories. Comma separated")
command.Flags().StringSliceVar(&includeTags, "include-tags", []string{}, "Include torrents with provided tags")
command.Flags().StringSliceVar(&excludeTags, "exclude-tags", []string{}, "Exclude torrents with provided tags")

Expand Down Expand Up @@ -66,6 +66,9 @@ func RunTorrentRemove() *cobra.Command {
options := qbittorrent.TorrentFilterOptions{}
if filter != "" {
options.Filter = qbittorrent.TorrentFilter(filter)
if len(includeCategory) == 0 {
includeCategory = []string{""}
}
}

if len(includeCategory) > 0 {
Expand Down

0 comments on commit d029c02

Please sign in to comment.