50 lines
757 B
Go
50 lines
757 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.apinb.com/bsm-sdk/engine/env"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
registryUrl string
|
|
)
|
|
|
|
func init() {
|
|
// get os env.
|
|
env.NewEnv()
|
|
|
|
psCmd.Flags().StringVarP(®istryUrl, "registry", "r", "", "registry url.")
|
|
|
|
if registryUrl == "" {
|
|
registryUrl = env.GetEnvDefault("BlocksMesh_Registry", "http://registry.apinb.com")
|
|
}
|
|
|
|
rootCmd.AddCommand(psCmd)
|
|
}
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "bsm",
|
|
Short: "bsm is a Blocks Service Mesh cli.",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Println("usage: bsm <command>")
|
|
},
|
|
}
|
|
|
|
func checkError(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
}
|
|
|
|
func Execute() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|