2024-05-03 17:11:56 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-07-06 18:28:44 +00:00
|
|
|
|
|
|
|
"github.com/ditatompel/xmr-remote-nodes/cmd/client"
|
|
|
|
"github.com/ditatompel/xmr-remote-nodes/internal/config"
|
2024-05-03 17:11:56 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2024-06-17 21:23:08 +00:00
|
|
|
var configFile string
|
|
|
|
|
2024-05-18 10:59:54 +00:00
|
|
|
var Root = &cobra.Command{
|
2024-05-03 17:11:56 +00:00
|
|
|
Use: "xmr-nodes",
|
|
|
|
Short: "XMR Nodes",
|
2024-07-03 20:45:37 +00:00
|
|
|
Version: config.Version,
|
2024-05-03 17:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Execute() {
|
2024-05-18 10:59:54 +00:00
|
|
|
err := Root.Execute()
|
2024-05-03 17:11:56 +00:00
|
|
|
if err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2024-06-17 21:23:08 +00:00
|
|
|
cobra.OnInitialize(initConfig)
|
|
|
|
Root.PersistentFlags().StringVarP(&configFile, "config-file", "c", "", "Default to .env")
|
2024-05-18 10:59:54 +00:00
|
|
|
Root.AddCommand(client.ProbeCmd)
|
2024-06-19 09:32:40 +00:00
|
|
|
client.ProbeCmd.Flags().StringP("endpoint", "e", "", "Server endpoint")
|
|
|
|
client.ProbeCmd.Flags().Bool("no-tor", false, "Only probe clearnet nodes")
|
2024-05-03 17:11:56 +00:00
|
|
|
}
|
2024-06-17 21:23:08 +00:00
|
|
|
|
|
|
|
func initConfig() {
|
|
|
|
if configFile != "" {
|
|
|
|
config.LoadAll(configFile)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
config.LoadAll(".env")
|
|
|
|
}
|