-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (37 loc) · 874 Bytes
/
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
47
48
package main
import (
"os"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const (
cliFlagDBDSN = "db-dsn"
cliFlagLogLevel = "log-level"
cliFlagLogDevel = "log-devel"
)
func bindDBDSNFlag(fs *pflag.FlagSet) {
fs.String(cliFlagDBDSN, "", "Database data source name to use.")
}
func createMainCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "sqlite-rest",
Short: "Serve a RESTful API from a SQLite database",
SilenceUsage: true,
}
cmd.PersistentFlags().
Int8(cliFlagLogLevel, 5, "Log level to use. Use 8 or more for verbose log.")
cmd.PersistentFlags().
Bool(cliFlagLogDevel, false, "Enable devel log format?")
cmd.AddCommand(
createServeCmd(),
createMigrateCmd(),
)
cmd.CompletionOptions.DisableDefaultCmd = true
return cmd
}
func main() {
cmd := createMainCmd()
if cmd.Execute() != nil {
os.Exit(1)
}
}