Skip to content

Commit

Permalink
add -v flags
Browse files Browse the repository at this point in the history
Signed-off-by: Clavin June <[email protected]>
  • Loading branch information
clavinjune committed Nov 4, 2021
1 parent 06a1097 commit 90f14b3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ import (
"github.com/ClavinJune/serve/internal"
)

const (
version string = "v0.2.0"
)

var (
portFlag *int
quietFlag *bool
rootFlag *string
spaFlag *bool
portFlag *int
quietFlag *bool
rootFlag *string
spaFlag *bool
versionFlag *bool
)

func init() {
portFlag = flag.Int("p", 1313, "port on which the server will listen")
quietFlag = flag.Bool("q", false, "run server quietly")
rootFlag = flag.String("r", ".", "root document which the server will serve")
spaFlag = flag.Bool("s", false, "serve single page application")
versionFlag = flag.Bool("v", false, "print current version")
flag.Parse()
}

Expand Down Expand Up @@ -76,6 +82,11 @@ func mustGetServer(rootDir string, isSpa bool) *http.Server {
}

func main() {
if *versionFlag {
fmt.Println("serve", version)
return
}

internal.LogSetQuite(*quietFlag)

rootDir := mustGetRootDirectory(*rootFlag)
Expand Down

0 comments on commit 90f14b3

Please sign in to comment.