Skip to content

Commit

Permalink
Merge pull request #250 from CircleCI-Public/orb-list-messaging
Browse files Browse the repository at this point in the history
[CIRCLE-15507, CIRCLE-15524] Improve messaging on `orb list`
  • Loading branch information
Zachary Scott authored Jan 4, 2019
2 parents df380e9 + b16405d commit c6a9c44
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
12 changes: 11 additions & 1 deletion cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"sort"
"strings"

"github.com/CircleCI-Public/circleci-cli/api"
"github.com/CircleCI-Public/circleci-cli/client"
Expand Down Expand Up @@ -353,7 +354,7 @@ func orbCollectionToString(orbCollection *api.OrbsForListing, opts orbOptions) (
if opts.listUncertified {
result += "Includes all certified and uncertified orbs.\n\n"
} else {
result += "Showing only certified orbs. Add -u for a list of all orbs.\n\n"
result += "Showing only certified orbs.\nAdd --uncertified for a list of all orbs.\n\n"
}
for _, orb := range orbCollection.Orbs {
if opts.listDetails {
Expand All @@ -362,6 +363,8 @@ func orbCollectionToString(orbCollection *api.OrbsForListing, opts orbOptions) (
result += (orbToSimpleString(orb))
}
}
result += "\nIn order to see more details about each orb, type: `circleci orb info orb-namespace/orb-name`\n"
result += "\nSearch, filter, and view sources for all Orbs online at https://circleci.com/orbs/registry/"
}

return result, nil
Expand Down Expand Up @@ -614,5 +617,12 @@ func orbInfo(opts orbOptions) error {
fmt.Printf("Projects: %d\n", info.Orb.Statistics.Last30DaysProjectCount)
fmt.Printf("Orgs: %d\n", info.Orb.Statistics.Last30DaysOrganizationCount)

orbVersionSplit := strings.Split(ref, "@")
orbRef := orbVersionSplit[0]
fmt.Printf(`
Learn more about this orb online in the CircleCI Orb Registry:
https://circleci.com/orbs/registry/orb/%s
`, orbRef)

return nil
}
36 changes: 32 additions & 4 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,12 +1189,16 @@ query ListOrbs ($after: String!, $certifiedOnly: Boolean!) {

// the orb named "second" actually has more builds
stdout := session.Wait().Out.Contents()
Expect(string(stdout)).To(Equal(`Orbs found: 3. Showing only certified orbs. Add -u for a list of all orbs.
Expect(string(stdout)).To(Equal(`Orbs found: 3. Showing only certified orbs.
Add --uncertified for a list of all orbs.
second (0.8.0)
third (0.9.0)
first (0.7.0)
In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `
Search, filter, and view sources for all Orbs online at https://circleci.com/orbs/registry/
`))
})

Expand All @@ -1212,12 +1216,16 @@ first (0.7.0)

// the orb named "third" actually has the most projects
stdout := session.Wait().Out.Contents()
Expect(string(stdout)).To(Equal(`Orbs found: 3. Showing only certified orbs. Add -u for a list of all orbs.
Expect(string(stdout)).To(Equal(`Orbs found: 3. Showing only certified orbs.
Add --uncertified for a list of all orbs.
third (0.9.0)
first (0.7.0)
second (0.8.0)
In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `
Search, filter, and view sources for all Orbs online at https://circleci.com/orbs/registry/
`))
})

Expand All @@ -1235,12 +1243,16 @@ second (0.8.0)

// the orb named "second" actually has the most orgs
stdout := session.Wait().Out.Contents()
Expect(string(stdout)).To(Equal(`Orbs found: 3. Showing only certified orbs. Add -u for a list of all orbs.
Expect(string(stdout)).To(Equal(`Orbs found: 3. Showing only certified orbs.
Add --uncertified for a list of all orbs.
second (0.8.0)
first (0.7.0)
third (0.9.0)
In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `
Search, filter, and view sources for all Orbs online at https://circleci.com/orbs/registry/
`))
})

Expand Down Expand Up @@ -1435,6 +1447,9 @@ query ListOrbs ($after: String!, $certifiedOnly: Boolean!) {
Eventually(session.Out).Should(gbytes.Say("circleci/codecov-clojure \\(0.0.4\\)"))
// Include an orb with contents from the second mocked response
Eventually(session.Out).Should(gbytes.Say("zzak/test4 \\(0.1.0\\)"))

Eventually(session.Out).Should(gbytes.Say("In order to see more details about each orb, type: `circleci orb info orb-namespace/orb-name`"))
Eventually(session.Out).Should(gbytes.Say("Search, filter, and view sources for all Orbs online at https://circleci.com/orbs/registry/"))
Expect(testServer.ReceivedRequests()).Should(HaveLen(2))
})

Expand Down Expand Up @@ -1524,7 +1539,8 @@ query ListOrbs ($after: String!, $certifiedOnly: Boolean!) {

Expect(err).ShouldNot(HaveOccurred())
stdout := session.Wait().Out.Contents()
Expect(string(stdout)).To(Equal(`Orbs found: 1. Showing only certified orbs. Add -u for a list of all orbs.
Expect(string(stdout)).To(Equal(`Orbs found: 1. Showing only certified orbs.
Add --uncertified for a list of all orbs.
foo/test (0.7.0)
Commands:
Expand All @@ -1541,6 +1557,9 @@ foo/test (0.7.0)
- last30DaysOrganizationCount: 0
- last30DaysProjectCount: 0
In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `
Search, filter, and view sources for all Orbs online at https://circleci.com/orbs/registry/
`))
Eventually(session).Should(gexec.Exit(0))
Expect(testServer.ReceivedRequests()).Should(HaveLen(1))
Expand Down Expand Up @@ -1970,6 +1989,9 @@ Total-jobs: 0
Builds: 0
Projects: 0
Orgs: 0
Learn more about this orb online in the CircleCI Orb Registry:
https://circleci.com/orbs/registry/orb/my/orb
`))

Eventually(session).Should(gexec.Exit(0))
Expand Down Expand Up @@ -2029,6 +2051,9 @@ Total-jobs: 0
Builds: 555
Projects: 777
Orgs: 999
Learn more about this orb online in the CircleCI Orb Registry:
https://circleci.com/orbs/registry/orb/my/orb
`))

Eventually(session).Should(gexec.Exit(0))
Expand Down Expand Up @@ -2074,6 +2099,9 @@ Total-jobs: 0
Builds: 0
Projects: 0
Orgs: 0
Learn more about this orb online in the CircleCI Orb Registry:
https://circleci.com/orbs/registry/orb/my/orb
`))

Eventually(session).Should(gexec.Exit(0))
Expand Down

0 comments on commit c6a9c44

Please sign in to comment.