-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroot.go
35 lines (29 loc) · 881 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"
"github.com/Diniboy1123/usque/config"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "usque",
Short: "Usque Warp CLI",
Long: "An unofficial Cloudflare Warp CLI that uses the MASQUE protocol and exposes the tunnel as various different services.",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
configPath, err := cmd.Flags().GetString("config")
if err != nil {
log.Fatalf("Failed to get config path: %v", err)
}
if configPath != "" {
if err := config.LoadConfig(configPath); err != nil {
log.Printf("Config file not found: %v", err)
log.Printf("You may only use the register command to generate one.")
}
}
},
}
func Execute() error {
return rootCmd.Execute()
}
func init() {
rootCmd.PersistentFlags().StringP("config", "c", "config.json", "config file (default is config.json)")
}