forked from TrueCloudLab/frostfs-locode-db
37 lines
965 B
Go
37 lines
965 B
Go
package main
|
|
|
|
import (
|
|
locodedb "git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode/db"
|
|
locodebolt "git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode/db/boltdb"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
locodeListCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "Print all locodes from FrostFS database",
|
|
Run: func(cmd *cobra.Command, _ []string) {
|
|
targetDB := locodebolt.New(locodebolt.Prm{
|
|
Path: locodeInfoDBPath,
|
|
}, locodebolt.ReadOnly())
|
|
|
|
err := targetDB.Open()
|
|
ExitOnErr(cmd, "", err)
|
|
|
|
defer targetDB.Close()
|
|
|
|
err = targetDB.IterateOverLocodes(func(locode string, geoPoint locodedb.Point) {
|
|
cmd.Printf("%s\t %0.2f %0.2f\n", locode, geoPoint.Latitude(), geoPoint.Longitude())
|
|
})
|
|
ExitOnErr(cmd, "", err)
|
|
},
|
|
}
|
|
)
|
|
|
|
func initUtilLocodeListCmd() {
|
|
flags := locodeListCmd.Flags()
|
|
|
|
flags.StringVar(&locodeInfoDBPath, locodeInfoDBFlag, "", locodeInfoDBFlagDesc)
|
|
_ = locodeListCmd.MarkFlagRequired(locodeInfoDBFlag)
|
|
|
|
}
|