github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/example/redirect/cmd/cli-redirect/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"github.com/ronaksoft/rony/config"
     8  	"github.com/ronaksoft/rony/tools"
     9  	"github.com/spf13/cobra"
    10  )
    11  
    12  func main() {
    13  	// Define the configs if this executable is running as a server instance
    14  	// Set the flags as config parameters
    15  	config.SetCmdFlags(ServerCmd,
    16  		config.StringFlag("server.id", tools.RandomID(12), ""),
    17  		config.StringFlag("gateway.listen", "0.0.0.0:80", ""),
    18  		config.StringSliceFlag("gateway.advertise.url", nil, ""),
    19  		config.StringFlag("tunnel.listen", "", ""),
    20  		config.StringSliceFlag("tunnel.advertise.url", nil, ""),
    21  		config.DurationFlag("idle-time", time.Minute, ""),
    22  		config.IntFlag("raft.port", 7080, ""),
    23  		config.Uint64Flag("replica-set", 1, ""),
    24  		config.IntFlag("gossip.port", 7081, ""),
    25  		config.StringFlag("data.path", "./_hdd", ""),
    26  		config.BoolFlag("bootstrap", false, ""),
    27  		config.StringFlag("seed", "", ""),
    28  	)
    29  
    30  	// Define the configs if this executable is running as a server instance
    31  	config.SetCmdFlags(ClientCmd,
    32  		config.StringFlag("host", "127.0.0.1", "the host of the seed server"),
    33  		config.IntFlag("port", 80, "the port of the seed server"),
    34  	)
    35  
    36  	RootCmd.AddCommand(ServerCmd, ClientCmd)
    37  
    38  	if err := RootCmd.Execute(); err != nil {
    39  		fmt.Println("we got error:", err)
    40  	}
    41  }
    42  
    43  var RootCmd = &cobra.Command{
    44  	Use: "echo",
    45  }