67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/debridmediamanager/zurg/internal"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func main() {
|
|
var configPath string // Variable to hold the config path
|
|
var testURL string // Variable to hold the download URL
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "zurg",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
internal.MainApp(configPath) // Pass the configPath to MainApp
|
|
},
|
|
}
|
|
|
|
// Adding a flag for the config path with a default value
|
|
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "./config.yml", "config file path")
|
|
|
|
var versionCmd = &cobra.Command{
|
|
Use: "version",
|
|
Short: "Prints zurg's current version",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
internal.ShowVersion()
|
|
},
|
|
}
|
|
|
|
var clearDownloadsCmd = &cobra.Command{
|
|
Use: "clear-downloads",
|
|
Short: "Clear all downloads (unrestricted links) in your account",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
internal.ClearDownloads()
|
|
},
|
|
}
|
|
|
|
var clearTorrentsCmd = &cobra.Command{
|
|
Use: "clear-torrents",
|
|
Short: "Clear all torrents in your account",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
internal.ClearTorrents()
|
|
},
|
|
}
|
|
|
|
var networkTestCmd = &cobra.Command{
|
|
Use: "network-test",
|
|
Short: "Test your network with RD servers",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
internal.NetworkTest(testURL) // Pass the downloadURL to NetworkTest
|
|
},
|
|
}
|
|
|
|
// Adding a flag for the test URL with a default value
|
|
networkTestCmd.Flags().StringVarP(&testURL, "test-url", "t", "", "URL to test network with")
|
|
|
|
rootCmd.AddCommand(versionCmd, clearDownloadsCmd, clearTorrentsCmd, networkTestCmd)
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|