feat: initial commit — unarr CLI
Search, inspect, stream, and download torrents from the terminal. Replaces the entire *arr stack with a single binary.
This commit is contained in:
commit
29cf0a0126
85 changed files with 10178 additions and 0 deletions
51
internal/cmd/recent.go
Normal file
51
internal/cmd/recent.go
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
tc "github.com/torrentclaw/go-client"
|
||||
|
||||
"github.com/torrentclaw/torrentclaw-cli/internal/ui"
|
||||
)
|
||||
|
||||
func newRecentCmd() *cobra.Command {
|
||||
var (
|
||||
limit int
|
||||
page int
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "recent",
|
||||
Short: "Show recently added content",
|
||||
Long: "Display the most recently added movies and TV shows to the catalog.",
|
||||
Example: ` unarr recent
|
||||
unarr recent --limit 20
|
||||
unarr recent --page 2 --json`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client := getClient()
|
||||
|
||||
resp, err := client.Recent(context.Background(), tc.RecentParams{Limit: limit, Page: page})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to fetch recent content: %w", err)
|
||||
}
|
||||
|
||||
if jsonOut {
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(resp)
|
||||
}
|
||||
|
||||
ui.PrintRecentItems(resp.Items)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().IntVar(&limit, "limit", 10, "number of results")
|
||||
cmd.Flags().IntVar(&page, "page", 0, "page number")
|
||||
|
||||
return cmd
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue