Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
corinnesollows committed Sep 23, 2022
2 parents 7e1b67d + eec8fd6 commit 0f90a2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,20 @@ var validSortFlag = map[string]bool{
"projects": true,
"orgs": true}

func validateSortFlag(sort string) error {
if _, valid := validSortFlag[sort]; valid {
func validateSortFlag(sortFlag string) error {
if _, valid := validSortFlag[sortFlag]; valid {
return nil
}
// TODO(zzak): we could probably reuse the map above to print the valid values
return fmt.Errorf("expected `%s` to be one of \"builds\", \"projects\", or \"orgs\"", sort)

keys := make([]string, 0, len(validSortFlag))
for key := range validSortFlag {
keys = append(keys, key)
}
sort.Strings(keys)

validFlags := fmt.Sprint(strings.Join(keys, ", "))

return fmt.Errorf("expected `%s` to be one of: %s", sortFlag, validFlags)
}

func listOrbs(opts orbOptions) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ Search, filter, and view sources for all Orbs online at https://circleci.com/dev
Eventually(session).Should(clitest.ShouldFail())

stderr := session.Wait().Err.Contents()
Expect(string(stderr)).To(Equal("Error: expected `idontknow` to be one of \"builds\", \"projects\", or \"orgs\"\n"))
Expect(string(stderr)).To(Equal("Error: expected `idontknow` to be one of: builds, orgs, projects\n"))
})
})

Expand Down

0 comments on commit 0f90a2f

Please sign in to comment.