Skip to content

Commit

Permalink
Fix: Fixes table generator to display multiline payloads correctly (#345
Browse files Browse the repository at this point in the history
)

* Updated cmds that output multiline values + refactored to use machinery

* Updated to latest machinery

* chore: go mod tidy

* Updated errant deletion

---------

Co-authored-by: Ben Jackson <shreddedbacon@users.noreply.github.com>
Co-authored-by: shreddedbacon <b@benjackson.email>
  • Loading branch information
3 people authored Jun 20, 2024
1 parent ad254f4 commit e1b98da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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

0 comments on commit e1b98da

Please sign in to comment.