Changed port type from int to uint16

This commit is contained in:
Seednode 2022-10-18 16:54:01 -05:00
parent 022b14bfa2
commit 0a546dd468
4 changed files with 9 additions and 10 deletions

View File

@ -22,9 +22,8 @@ Available Commands:
version Print version version Print version
Flags: Flags:
-f, --filter string only display images matching specified pattern (case-insensitive)
-h, --help help for roulette -h, --help help for roulette
-p, --port int port to listen on (default 8080) -p, --port uint16 port to listen on (default 8080)
-r, --recursive recurse into subdirectories -r, --recursive recurse into subdirectories
-v, --verbose log accessed files to stdout -v, --verbose log accessed files to stdout

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Port int var Port uint16
var Recursive bool var Recursive bool
var Verbose bool var Verbose bool
@ -31,7 +31,7 @@ func Execute() {
} }
func init() { func init() {
rootCmd.Flags().IntVarP(&Port, "port", "p", 8080, "port to listen on") rootCmd.Flags().Uint16VarP(&Port, "port", "p", 8080, "port to listen on")
rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories") rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories")
rootCmd.Flags().BoolVarP(&Verbose, "verbose", "v", false, "log accessed files to stdout") rootCmd.Flags().BoolVarP(&Verbose, "verbose", "v", false, "log accessed files to stdout")
rootCmd.Flags().SetInterspersed(true) rootCmd.Flags().SetInterspersed(true)

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Version = "0.13.2" var Version = "0.13.3"
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)

View File

@ -320,7 +320,7 @@ func ServePage(args []string) error {
http.Handle(PREFIX+"/", http.StripPrefix(PREFIX, serveStaticFileHandler(paths))) http.Handle(PREFIX+"/", http.StripPrefix(PREFIX, serveStaticFileHandler(paths)))
http.HandleFunc("/favicon.ico", doNothing) http.HandleFunc("/favicon.ico", doNothing)
err = http.ListenAndServe(":"+strconv.Itoa(Port), nil) err = http.ListenAndServe(":"+strconv.FormatInt(int64(Port), 10), nil)
if err != nil { if err != nil {
return err return err
} }