From 5276976158a552a888d2f4af1cc2db8936262429 Mon Sep 17 00:00:00 2001 From: fedeberco Date: Mon, 30 Nov 2020 13:54:58 -0300 Subject: [PATCH 1/4] configure flags --- cmd/call/call.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/call/call.go b/cmd/call/call.go index 6036d05f..c178aea2 100644 --- a/cmd/call/call.go +++ b/cmd/call/call.go @@ -4,8 +4,8 @@ import ( "bytes" "context" "encoding/json" - "flag" "fmt" + "github.com/spf13/pflag" "github.com/spf13/cobra" "github.com/wearefair/gurl/pkg/config" @@ -39,9 +39,11 @@ var CallCmd = &cobra.Command{ func init() { flags := CallCmd.Flags() - // Add any flags that were registered on the built-in flag package. - flags.AddGoFlagSet(flag.CommandLine) + ConfigureFlags(flags) +} +//function to configure flags not only in this project but for those projects that import this one +func ConfigureFlags(flags *pflag.FlagSet){ flags.StringVarP(&uri, "uri", "u", "", "gRPC URI in the form of host:port/service_name/method_name") flags.StringVarP(&data, "data", "d", "", "Data, as JSON string, to send to the gRPC service") CallCmd.MarkFlagRequired("uri") From 81a68c60c79c6411c725b39ee5fbb4f27039e962 Mon Sep 17 00:00:00 2001 From: fedeberco Date: Mon, 30 Nov 2020 16:21:27 -0300 Subject: [PATCH 2/4] addings flags again --- cmd/call/call.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/call/call.go b/cmd/call/call.go index c178aea2..b8e0bebc 100644 --- a/cmd/call/call.go +++ b/cmd/call/call.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "flag" "fmt" "github.com/spf13/pflag" @@ -39,6 +40,9 @@ var CallCmd = &cobra.Command{ func init() { flags := CallCmd.Flags() + // Add any flags that were registered on the built-in flag package. + flags.AddGoFlagSet(flag.CommandLine) + ConfigureFlags(flags) } From 6d7478103232cb6467c6b43926895177a810a4e3 Mon Sep 17 00:00:00 2001 From: fedeberco Date: Mon, 30 Nov 2020 16:32:00 -0300 Subject: [PATCH 3/4] fmt --- cmd/call/call.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/call/call.go b/cmd/call/call.go index b8e0bebc..06dfc002 100644 --- a/cmd/call/call.go +++ b/cmd/call/call.go @@ -46,7 +46,7 @@ func init() { ConfigureFlags(flags) } -//function to configure flags not only in this project but for those projects that import this one +// Configure flags not only in this project but for those projects that import this one func ConfigureFlags(flags *pflag.FlagSet){ flags.StringVarP(&uri, "uri", "u", "", "gRPC URI in the form of host:port/service_name/method_name") flags.StringVarP(&data, "data", "d", "", "Data, as JSON string, to send to the gRPC service") From 582741d0cccd5987974f4c00e76c8f3448cfd789 Mon Sep 17 00:00:00 2001 From: fedeberco Date: Mon, 30 Nov 2020 16:36:06 -0300 Subject: [PATCH 4/4] fix description --- cmd/call/call.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/call/call.go b/cmd/call/call.go index 06dfc002..aea886be 100644 --- a/cmd/call/call.go +++ b/cmd/call/call.go @@ -46,7 +46,7 @@ func init() { ConfigureFlags(flags) } -// Configure flags not only in this project but for those projects that import this one +// ConfigureFlags registers the flags not only in this project but for those projects that import this one func ConfigureFlags(flags *pflag.FlagSet){ flags.StringVarP(&uri, "uri", "u", "", "gRPC URI in the form of host:port/service_name/method_name") flags.StringVarP(&data, "data", "d", "", "Data, as JSON string, to send to the gRPC service")