9ce12452288e — Dang Hoang Tuan (Tsuki) 1 year, 11 months ago
Remove ACCESSIBLE_DIR and PORT constants since we now have defaults for our CLI arguments/flags
3 files changed, 2 insertions(+), 11 deletions(-)

M consts.go
M main.go
M server.go
M consts.go +0 -2
@@ 24,5 24,3 @@ be:
 `
 var spf = fmt.Sprintf
 var sp = fmt.Sprint
-var ACCESSIBLE_DIR string = "./" // Accessible directory
-var PORT int = 1323 // Default port

          
M main.go +2 -2
@@ 8,8 8,8 @@ import (
 
 type Flags struct {
   cli.Helper
-  Port int `cli:"p,port" usage:"Port number (default is 1323)"`
-  Directory string `cli:"d,dir" usage:"Directory to display (default is .)"`
+  Port int `cli:"p,port" usage:"Port number (default is 1323)" dft:1323`
+  Directory string `cli:"d,dir" usage:"Directory to display (default is .)" dft:"."`
 }
 
 func main() {

          
M server.go +0 -7
@@ 28,13 28,6 @@ func index(c echo.Context) error {
 }
 
 func serve(port int, dir string) {
-	// Processing CLI arguments
-	if port != 0 {
-		PORT = port
-	}
-	if dir != "" {
-		ACCESSIBLE_DIR = dir 
-	}
   e := echo.New()
 	e.GET("/", index)
 	e.Logger.Fatal(e.Start(spf(":%d", port)))