From da19c4bad998f82c6b26b0202a23da4cb737fa02 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Sat, 1 Feb 2020 11:02:02 +0100 Subject: [PATCH] Add "providers" command alias --- README.md | 4 +-- newreleases/cmd/{provider.go => providers.go} | 5 +-- .../{provider_test.go => providers_test.go} | 32 ++++++++++--------- 3 files changed, 22 insertions(+), 19 deletions(-) rename newreleases/cmd/{provider.go => providers.go} (95%) rename newreleases/cmd/{provider_test.go => providers_test.go} (78%) diff --git a/README.md b/README.md index 7de4819..f1a4d59 100644 --- a/README.md +++ b/README.md @@ -236,13 +236,13 @@ newreleases release note gzetyksdfeyxt4mdsbe60td5gw 2.6.11 NewReleases supports a number of clients and they can be listed with: ```sh -newreleases provider +newreleases providers ``` To list only providers that you have project added from: ```sh -newreleases provider --added +newreleases providers --added ``` This information can be useful when filtering projects by a provider. diff --git a/newreleases/cmd/provider.go b/newreleases/cmd/providers.go similarity index 95% rename from newreleases/cmd/provider.go rename to newreleases/cmd/providers.go index a519885..e0f62cb 100644 --- a/newreleases/cmd/provider.go +++ b/newreleases/cmd/providers.go @@ -15,8 +15,9 @@ func (c *command) initProviderCmd() (err error) { optionNameAdded := "added" cmd := &cobra.Command{ - Use: "provider", - Short: "Get project providers", + Use: "providers", + Aliases: []string{"provider"}, + Short: "Get project providers", RunE: func(cmd *cobra.Command, args []string) (err error) { ctx, cancel := newClientContext(c.config) defer cancel() diff --git a/newreleases/cmd/provider_test.go b/newreleases/cmd/providers_test.go similarity index 78% rename from newreleases/cmd/provider_test.go rename to newreleases/cmd/providers_test.go index 9ae7977..b150af9 100644 --- a/newreleases/cmd/provider_test.go +++ b/newreleases/cmd/providers_test.go @@ -50,22 +50,24 @@ func TestProviderCmd(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - args := []string{"provider"} - if tc.added { - args = append(args, "--added") - } - var outputBuf bytes.Buffer - if err := newCommand(t, - cmd.WithArgs(args...), - cmd.WithOutput(&outputBuf), - cmd.WithProvidersService(tc.providersService), - ).Execute(); err != tc.wantError { - t.Fatalf("got error %v, want %v", err, tc.wantError) - } + for _, alias := range []string{"providers", "provider"} { + args := []string{alias} + if tc.added { + args = append(args, "--added") + } + var outputBuf bytes.Buffer + if err := newCommand(t, + cmd.WithArgs(args...), + cmd.WithOutput(&outputBuf), + cmd.WithProvidersService(tc.providersService), + ).Execute(); err != tc.wantError { + t.Fatalf("got error %v, want %v", err, tc.wantError) + } - gotOutput := outputBuf.String() - if gotOutput != tc.wantOutput { - t.Errorf("got output %q, want %q", gotOutput, tc.wantOutput) + gotOutput := outputBuf.String() + if gotOutput != tc.wantOutput { + t.Errorf("got output %q, want %q", gotOutput, tc.wantOutput) + } } }) }