-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
35 lines (29 loc) · 879 Bytes
/
root.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
package cmd
import (
"log"
"os"
"github.com/1995parham-teaching/tinyurl/internal/cmd/migrate"
"github.com/1995parham-teaching/tinyurl/internal/cmd/seed"
"github.com/1995parham-teaching/tinyurl/internal/cmd/server"
"github.com/carlmjohnson/versioninfo"
"github.com/spf13/cobra"
)
// ExitFailure status code.
const ExitFailure = 1
// 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() {
//nolint: exhaustruct
root := &cobra.Command{
Use: "tinyurl",
Short: "Shorten your URLs to make them more memorable",
Version: versioninfo.Short(),
}
server.Register(root)
migrate.Register(root)
seed.Register(root)
if err := root.Execute(); err != nil {
log.Printf("failed to execute root command %s", err)
os.Exit(ExitFailure)
}
}