diff --git a/cmd/client.go b/cmd/client.go index 3cbb750..25aa1c1 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -17,9 +17,18 @@ var clientCmd = &cobra.Command{ logrus.Error("You must provide a name for the service") return } + + pbImportPath := viper.GetString("g_c_pb_import_path") + if viper.GetString("g_c_transport") == "grpc" { + if pbImportPath == "" { + logrus.Error("You must provide pb import path by --pb_import_path or -i, because transport is grpc") + return + } + } g := generator.NewGenerateClient( args[0], viper.GetString("g_c_transport"), + pbImportPath, ) if err := g.Generate(); err != nil { logrus.Error(err) @@ -30,7 +39,9 @@ var clientCmd = &cobra.Command{ func init() { generateCmd.AddCommand(clientCmd) clientCmd.Flags().StringP("transport", "t", "http", "The transport you want your client to be initiated") + clientCmd.Flags().StringP("pb_import_path", "i", "", "Specify path to import pb") viper.BindPFlag("g_c_transport", clientCmd.Flags().Lookup("transport")) + viper.BindPFlag("g_c_pb_import_path", clientCmd.Flags().Lookup("pb_import_path")) // Here you will define your flags and configuration settings. // Cobra supports Persistent Flags which will work for this command