Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table generator to display multiline payloads correctly #345

Merged
merged 8 commits into from
Jun 20, 2024
2 changes: 2 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var listDeployTargetsCmd = &cobra.Command{
returnNonEmptyString(fmt.Sprintf("%v", deploytarget.MonitoringConfig)),
})
}
outputOptions.MultiLine = true
output.RenderOutput(output.Table{
Header: []string{
"ID",
Expand Down Expand Up @@ -386,6 +387,7 @@ var listVariablesCmd = &cobra.Command{
env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Name)))
if reveal {
env = append(env, fmt.Sprintf("%v", envvar.Value))
outputOptions.MultiLine = true
}
data = append(data, env)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ var getUserKeysCmd = &cobra.Command{
Data: data,
}

outputOptions.MultiLine = true
output.RenderOutput(dataMain, outputOptions)
return nil
},
Expand Down Expand Up @@ -490,7 +491,7 @@ var getAllUserKeysCmd = &cobra.Command{
Header: []string{"ID", "Email", "Name", "Type", "Value"},
Data: data,
}

outputOptions.MultiLine = true
output.RenderOutput(dataMain, outputOptions)
return nil
},
Expand Down
8 changes: 8 additions & 0 deletions pkg/output/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ func RenderOutput(data Table, opts Options) {
if !opts.MultiLine {
t.SuppressTrailingSpaces() // suppress the trailing spaces if not multiline
}
if opts.MultiLine {
// stops multiline values bleeding into other columns
t.SetColumnConfigs([]table.ColumnConfig{
{Name: "Value", WidthMax: 75}, // Set specific width for "Value" column if multiline
{Name: "Token", WidthMax: 50}, // Set specific width for "Token" column if multiline
})
}

if opts.CSV {
t.RenderCSV()
return
Expand Down
Loading