do a few
This commit is contained in:
parent
a6ef3bf1b6
commit
f174c4e02d
14 changed files with 626 additions and 1 deletions
37
cmd/root.go
Normal file
37
cmd/root.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
ip net.IP
|
||||
port uint16
|
||||
proto string
|
||||
v6 bool
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "protohacking",
|
||||
Short: "Protohackers challenge servers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
pflags := rootCmd.PersistentFlags()
|
||||
pflags.Uint16VarP(&port, "port", "p", 8088, "Port to TCP listen on")
|
||||
pflags.IPVarP(&ip, "ip", "i", net.IPv6unspecified, "Address to listen on")
|
||||
pflags.BoolVarP(&v6, "v6", "6", true, "Whether to use IPv6")
|
||||
pflags.StringVar(&proto, "proto", "tcp", "Either tcp or udp")
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
log.Fatal("fatal error", "err", err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue