Skip to content

Commit

Permalink
chore: right-align num
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Mar 30, 2023
1 parent b58bc99 commit 46565ce
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions cmds/cost/aws/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ func get(cmd *cobra.Command, args []string, fl *Flags) {

refCols[13].enable = in.AwsOptions.IncludeTags
refCols[14].enable = in.AwsOptions.IncludeCostCategories

stream, err = client.ReadCosts(ctx, &in)
if err != nil {
fnerr(err)
Expand Down Expand Up @@ -295,17 +294,31 @@ func get(cmd *cobra.Command, args []string, fl *Flags) {
}
}

colsAlign := []int{}
for _, col := range cols {
switch {
case col == "USAGE":
fallthrough
case col == "COST":
colsAlign = append(colsAlign, tablewriter.ALIGN_RIGHT)
default:
colsAlign = append(colsAlign, tablewriter.ALIGN_LEFT)
}
}

table := tablewriter.NewWriter(os.Stdout)
table.SetAutoFormatHeaders(false)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table.SetAlignment(tablewriter.ALIGN_LEFT)
// table.SetAutoFormatHeaders(false)
// table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
// table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetColWidth(fl.ColWidth)
table.SetBorder(false)
table.SetHeaderLine(false)
table.SetColumnSeparator("")
table.SetTablePadding(" ")
table.SetNoWhiteSpace(true)
table.SetHeader(cols)
// table.SetHeader(cols)
table.SetColumnAlignment(colsAlign)
table.Append(cols)
var render bool

for {
Expand Down

0 comments on commit 46565ce

Please sign in to comment.