feat: stream download cli
This commit is contained in:
29
cmd/root.go
Normal file
29
cmd/root.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user