frostfs-locode-db/main.go
Anton Nikiforov 1c14038948 [#13] locode: Add command to list all locodes
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
2025-03-12 10:21:02 +03:00

49 lines
915 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() {
// use stdout as default output for cmd.Print()
rootCmd.SetOut(os.Stdout)
initUtilLocodeGenerateCmd()
initUtilLocodeInfoCmd()
initUtilLocodeListCmd()
rootCmd.AddCommand(locodeGenerateCmd, locodeInfoCmd, locodeListCmd)
err := rootCmd.Execute()
if err != nil {
ExitOnErr(rootCmd, "", err)
}
}