Files
sdl/cmd/root.go

30 lines
606 B
Go

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)
}
}