Skip to content

Commit

Permalink
Add "providers" command alias
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Feb 1, 2020
1 parent 56ba309 commit da19c4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions newreleases/cmd/provider.go → newreleases/cmd/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
})
}
Expand Down

0 comments on commit da19c4b

Please sign in to comment.