Files
zurg/cmd/zurg/main.go
2023-11-29 23:10:55 +01:00

47 lines
1006 B
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()
},
}
rootCmd.AddCommand(versionCmd, networkTestCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}