github.com/sagernet/sing-box@v1.9.0-rc.20/cmd/sing-box/cmd_geoip_list.go (about) 1 package main 2 3 import ( 4 "os" 5 6 "github.com/sagernet/sing-box/log" 7 8 "github.com/spf13/cobra" 9 ) 10 11 var commandGeoipList = &cobra.Command{ 12 Use: "list", 13 Short: "List geoip country codes", 14 Run: func(cmd *cobra.Command, args []string) { 15 err := listGeoip() 16 if err != nil { 17 log.Fatal(err) 18 } 19 }, 20 } 21 22 func init() { 23 commandGeoip.AddCommand(commandGeoipList) 24 } 25 26 func listGeoip() error { 27 for _, code := range geoipReader.Metadata.Languages { 28 os.Stdout.WriteString(code + "\n") 29 } 30 return nil 31 }