-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (36 loc) · 1.21 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2020 PJ Engineering and Business Solutions Pty. Ltd. All rights reserved.
package main
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
)
var VERSION = "" // Use git tag: $(git describe --always)
var GITCOMMIT = "" // Use current git commit id: $(git rev-parse --short HEAD)
func main() {
var versionCmd = &cobra.Command{
Use: "version",
Short: "Version prints the version of friendly",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("friendly version: " + VERSION + " (" + GITCOMMIT + ")")
os.Exit(0)
},
}
var rootCmd = &cobra.Command{
Use: "friendly",
Run: runCmd,
}
rootCmd.AddCommand(versionCmd)
rootCmd.Flags().StringP("port", "p", "", "listen port (default: 8080 [http] & 4430 [https])")
rootCmd.Flags().StringP("path", "d", ".", "directory of files")
rootCmd.Flags().BoolP("https", "s", false, "enable https")
rootCmd.Flags().BoolP("browser", "b", false, "open site on browser")
rootCmd.Flags().Bool("save", false, "save ssl certificate for reuse")
rootCmd.Flags().BoolP("remove", "r", false, "remove stored ssl certificate")
rootCmd.Flags().BoolP("quiet", "q", false, "don't produce logs")
err := rootCmd.Execute()
if err != nil {
log.Fatal(err)
}
}