63 lines
1.4 KiB
Go
63 lines
1.4 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 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()
|
|
},
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|