Files
zurg/cmd/zurg/main.go
2024-01-11 01:26:43 +01:00

66 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 netTestType string // Variable to hold the network test type
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 networkTestCmd = &cobra.Command{
Use: "network-test",
Short: "Run a network test",
Run: func(cmd *cobra.Command, args []string) {
internal.NetworkTest(netTestType) // Pass the network test type to NetworkTest
},
}
// Adding a flag for network test type with default value "both"
networkTestCmd.Flags().StringVarP(&netTestType, "type", "t", "both", "network test type (ipv4, ipv6, both)")
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()
},
}
rootCmd.AddCommand(versionCmd, networkTestCmd, clearDownloadsCmd, clearTorrentsCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}