Skip to content

Commit

Permalink
add flag -i pb_import_path
Browse files Browse the repository at this point in the history
  • Loading branch information
chaseSpace committed Sep 6, 2020
1 parent a85f301 commit e4ad444
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit e4ad444

Please sign in to comment.