feat: stream download cli

This commit is contained in:
2025-10-10 21:01:34 +02:00
commit 3f46bcc1bd
7 changed files with 375 additions and 0 deletions

29
cmd/root.go Normal file
View File

@@ -0,0 +1,29 @@
package cmd
import (
"os"
"github.com/spf13/cobra"
"sdl/internal/downloader"
)
var rootCmd = &cobra.Command{
Use: "sdl [URL]",
Short: "Stream downloader for HTTP Live Streaming (HLS) content",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
url := args[0]
output, _ := cmd.Flags().GetString("output")
return downloader.Download(cmd.Context(), url, output)
},
}
func init() {
rootCmd.Flags().StringP("output", "o", "", "Output file name (defaults to basename of stream)")
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}