add bind option (#17)

* add bind option
This commit is contained in:
legiz-ru
2025-04-06 07:03:37 +03:00
committed by GitHub
parent a61bb1718e
commit 87e06ffc67
2 changed files with 10 additions and 5 deletions

View File

@ -6,10 +6,14 @@ import (
"github.com/spf13/cobra"
)
var port uint16
var (
port uint16
bind string
)
func init() {
runCmd.Flags().Uint16VarP(&port, "port", "p", 8080, "server port")
runCmd.Flags().StringVarP(&bind, "bind", "b", "0.0.0.0", "bind address (e.g., 0.0.0.0, 127.0.0.1, localhost)")
RootCmd.AddCommand(runCmd)
}
@ -18,6 +22,6 @@ var runCmd = &cobra.Command{
Long: "Run the server",
Short: "Run the server",
Run: func(cmd *cobra.Command, args []string) {
api.RunServer(port)
api.RunServer(bind, port)
},
}