Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ var contextsCmd = cobra.Command{
}

table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"ClientID", "Username", "Grant Type"})
table.Header("ClientID", "Username", "Grant Type")
for _, context := range c.GetActiveTarget().Contexts {
table.Append([]string{context.ClientId, context.Username, string(context.GrantType)})
_ = table.Append(context.ClientId, context.Username, string(context.GrantType))
}
table.Render()
_ = table.Render()
},
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/contexts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var _ = Describe("Contexts", func() {
Describe("when no target was previously set", func() {
BeforeEach(func() {
c := config.NewConfig()
config.WriteConfig(c)
Expect(config.WriteConfig(c)).Error().ShouldNot(HaveOccurred())
})

It("tells the user to set a target", func() {
Expand All @@ -27,7 +27,7 @@ var _ = Describe("Contexts", func() {
Describe("when a target was previously set but there is no active context", func() {
BeforeEach(func() {
c := config.NewConfigWithServerURL("http://login.somewhere.com")
config.WriteConfig(c)
Expect(config.WriteConfig(c)).Error().ShouldNot(HaveOccurred())
})

It("tells the user to set a context", func() {
Expand All @@ -44,14 +44,14 @@ var _ = Describe("Contexts", func() {
c := config.NewConfigWithServerURL("http://login.somewhere.com")
ctx1 := config.UaaContext{ClientId: "admin", Username: "woodstock", GrantType: config.PASSWORD}
c.AddContext(ctx1)
config.WriteConfig(c)
Expect(config.WriteConfig(c)).Error().ShouldNot(HaveOccurred())
})

It("prints a table of results", func() {
session := runCommand("contexts")

// Headings
Expect(session.Out).Should(Say("CLIENTID"))
Expect(session.Out).Should(Say("CLIENT ID"))
Expect(session.Out).Should(Say("USERNAME"))
Expect(session.Out).Should(Say("GRANT TYPE"))

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.24
require (
github.com/cloudfoundry-community/go-uaa v0.3.5
github.com/fatih/color v1.18.0
github.com/olekukonko/tablewriter v0.0.5
github.com/olekukonko/tablewriter v1.0.7
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.37.0
github.com/pkg/errors v0.9.1
Expand All @@ -24,6 +24,8 @@ require (
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 // indirect
github.com/olekukonko/ll v0.0.8 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.6 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 h1:r3FaAI0NZK3hSmtTDrBVREhKULp8oUeqLT5Eyl2mSPo=
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
github.com/olekukonko/ll v0.0.8 h1:sbGZ1Fx4QxJXEqL/6IG8GEFnYojUSQ45dJVwN2FH2fc=
github.com/olekukonko/ll v0.0.8/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g=
github.com/olekukonko/tablewriter v1.0.7 h1:HCC2e3MM+2g72M81ZcJU11uciw6z/p82aEnm4/ySDGw=
github.com/olekukonko/tablewriter v1.0.7/go.mod h1:H428M+HzoUXC6JU2Abj9IT9ooRmdq9CxuDmKMtrOCMs=
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
Expand Down