forked from TrueCloudLab/frostfs-locode-db
George Bartolomey
840b20538b
Added frostfs-locode-db CLI utility that can generate and view UN/LOCODE database files. Go package git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/locode copied to this repository to eliminate interdependency between frostfs-node and frostfs-locode-db projects. The process of building database files reduced to starting make command. Signed-off-by: George Bartolomey <george@bh4.ru>
45 lines
798 B
Go
45 lines
798 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "frostfs-locode-db",
|
|
Short: "Command Line Tool to work with FrostFS' UN/LOCODE databases",
|
|
Long: "This tool can be used for generating or accessing FrostFS UN/LOCODE databases.",
|
|
}
|
|
|
|
func ExitOnErr(cmd *cobra.Command, errFmt string, err error) {
|
|
if err == nil {
|
|
return
|
|
}
|
|
|
|
if errFmt != "" {
|
|
err = fmt.Errorf(errFmt, err)
|
|
}
|
|
|
|
const (
|
|
_ = iota
|
|
internal
|
|
aclDenied
|
|
)
|
|
cmd.PrintErrln(err)
|
|
if cmd.PersistentPostRun != nil {
|
|
cmd.PersistentPostRun(cmd, nil)
|
|
}
|
|
os.Exit(internal)
|
|
}
|
|
|
|
func main() {
|
|
initUtilLocodeGenerateCmd()
|
|
initUtilLocodeInfoCmd()
|
|
rootCmd.AddCommand(locodeGenerateCmd, locodeInfoCmd)
|
|
err := rootCmd.Execute()
|
|
if err != nil {
|
|
ExitOnErr(rootCmd, "", err)
|
|
}
|
|
}
|