2020-07-17 12:12:04 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2022-05-05 11:49:11 +08:00
|
|
|
"strings"
|
2020-07-17 12:12:04 +08:00
|
|
|
|
2022-05-09 14:48:28 +08:00
|
|
|
"github.com/zu1k/nali/internal/db"
|
|
|
|
|
2021-08-03 07:54:35 +08:00
|
|
|
"github.com/spf13/cobra"
|
2020-07-17 12:12:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// updateCmd represents the update command
|
|
|
|
var updateCmd = &cobra.Command{
|
2022-05-05 11:49:11 +08:00
|
|
|
Use: "update",
|
2022-05-09 14:48:28 +08:00
|
|
|
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",
|
2020-07-17 12:12:04 +08:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2022-05-05 11:49:11 +08:00
|
|
|
DBs, _ := cmd.Flags().GetString("db")
|
|
|
|
var DBNameArray []string
|
|
|
|
if DBs != "" {
|
|
|
|
DBNameArray = strings.Split(DBs, ",")
|
|
|
|
}
|
|
|
|
db.UpdateDB(DBNameArray...)
|
2020-07-17 12:12:04 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(updateCmd)
|
2022-05-05 11:49:11 +08:00
|
|
|
rootCmd.PersistentFlags().String("db", "", "choose db you want to update")
|
2020-07-17 12:12:04 +08:00
|
|
|
}
|