mirror of
https://github.com/nxtrace/nali
synced 2024-11-23 02:38:11 +00:00
fix: #155
This commit is contained in:
parent
a77165b014
commit
8aebd93126
31
cmd/info.go
Normal file
31
cmd/info.go
Normal file
@ -0,0 +1,31 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zu1k/nali/internal/constant"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// infoCmd represents the info command
|
||||
var infoCmd = &cobra.Command{
|
||||
Use: "info",
|
||||
Short: "get the necessary information of nali",
|
||||
Long: `get the necessary information of nali`,
|
||||
Example: "nali info",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Nali Version: ", constant.Version)
|
||||
fmt.Println("Config Dir Path: ", constant.ConfigDirPath)
|
||||
fmt.Println("DB Data Dir Path: ", constant.DataDirPath)
|
||||
|
||||
fmt.Println("Selected IPv4 DB: ", viper.GetString("selected.ipv4"))
|
||||
fmt.Println("Selected IPv6 DB: ", viper.GetString("selected.ipv6"))
|
||||
fmt.Println("Selected CDN DB: ", viper.GetString("selected.cdn"))
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(infoCmd)
|
||||
}
|
@ -25,6 +25,6 @@ var updateCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
updateCmd.PersistentFlags().String("db", "", "choose db you want to update")
|
||||
rootCmd.AddCommand(updateCmd)
|
||||
rootCmd.PersistentFlags().String("db", "", "choose db you want to update")
|
||||
}
|
||||
|
@ -14,6 +14,20 @@ func migration2v6() {
|
||||
return
|
||||
}
|
||||
oldDefaultWorkPath := filepath.Join(homeDir, ".nali")
|
||||
|
||||
oldDefaultWorkPath, err = filepath.Abs(oldDefaultWorkPath)
|
||||
if err != nil {
|
||||
log.Errorf("Get absolute path for oldDefaultWorkPath failed: %s\n", err)
|
||||
}
|
||||
mewWorkPath, err := filepath.Abs(constant.ConfigDirPath)
|
||||
if err != nil {
|
||||
log.Errorf("Get absolute path for mewWorkPath failed: %s\n", err)
|
||||
}
|
||||
if oldDefaultWorkPath == mewWorkPath {
|
||||
// User chooses to continue using old directory
|
||||
return
|
||||
}
|
||||
|
||||
_, err = os.Stat(oldDefaultWorkPath)
|
||||
if err == nil {
|
||||
println("Old data directories are detected and will attempt to migrate automatically")
|
||||
|
Loading…
Reference in New Issue
Block a user