1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 21:29:02 +08:00
nali/cmd/update.go
zu1k c0643f7731 feat: Database from config
Signed-off-by: zu1k <i@zu1k.com>
2022-05-09 14:48:28 +08:00

31 lines
732 B
Go

package cmd
import (
"strings"
"github.com/zu1k/nali/internal/db"
"github.com/spf13/cobra"
)
// updateCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Short: "update qqwry, zxipv6wry, ip2region ip database and cdn",
Long: `update qqwry, zxipv6wry, ip2region ip database and cdn. Use commas to separate`,
Example: "nali update --db qqwry,cdn",
Run: func(cmd *cobra.Command, args []string) {
DBs, _ := cmd.Flags().GetString("db")
var DBNameArray []string
if DBs != "" {
DBNameArray = strings.Split(DBs, ",")
}
db.UpdateDB(DBNameArray...)
},
}
func init() {
rootCmd.AddCommand(updateCmd)
rootCmd.PersistentFlags().String("db", "", "choose db you want to update")
}