ソースを参照

Add Commandline Usage Help.

zry 4 年 前
コミット
cbf2b74afc
3 ファイル変更7 行追加0 行削除
  1. BIN
      SimpleHttpTestServer_Win32.exe
  2. BIN
      SimpleHttpTestServer_linux_linux
  3. 7 0
      main.go

BIN
SimpleHttpTestServer_Win32.exe


BIN
SimpleHttpTestServer_linux_linux


+ 7 - 0
main.go

@@ -8,10 +8,17 @@ import (
 
 var BindPort uint
 var PathToServe string
+var ShowHelp bool
 
 func main() {
+	flag.BoolVar(&ShowHelp, "h", false, "Show this help message.")
 	flag.UintVar(&BindPort, "b", 8000, "Port to bind")
 	flag.StringVar(&PathToServe, "f", "./", "Path to serve")
+	flag.Parse()
+	if ShowHelp {
+		flag.PrintDefaults()
+		return
+	}
 	http.Handle("/", http.FileServer(http.Dir(PathToServe)))
 	err := http.ListenAndServe(fmt.Sprintf(":%d", BindPort), nil)
 	if err != nil {