-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
78 lines (59 loc) · 1.8 KB
/
cli.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
"os"
"github.com/afairon/shlink-server/utils"
"github.com/spf13/cobra"
)
const (
// Logo is the application banner
Logo = `
_____ _ _ _ _ _____
/ ____| | | (_) | | / ____|
| (___ | |__ | |_ _ __ | | __ | (___ ___ _ ____ _____ _ __
\___ \| '_ \| | | '_ \| |/ / \___ \ / _ \ '__\ \ / / _ \ '__|
____) | | | | | | | | | < ____) | __/ | \ V / __/ |
|_____/|_| |_|_|_|_| |_|_|\_\ |_____/ \___|_| \_/ \___|_|
`
copyrights = `(C) Copyright 2018 Shlink. All Rights Reserved.`
)
var (
// NoBanner will display banner.
NoBanner bool
// Start will start http server.
Start bool
// Verbose will enable go-chi verbose mode.
Verbose bool
// version is the server version.
version string
// platform is the server platform.
platform string
// goVersion is the server compiled go version.
goVersion string
// goPlatform is the server compiled go platform.
goPlatform string
)
// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "shlink",
Short: Logo + copyrights,
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
cmdServer.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "Enable verbose")
RootCmd.PersistentFlags().BoolVar(&NoBanner, "no-banner", false, "Don't display banner")
RootCmd.AddCommand(cmdServer)
RootCmd.AddCommand(cmdVersion)
RootCmd.AddCommand(config)
}
func main() {
utils.Conf.ReadConfig()
Execute()
}