Skip to content

Commit

Permalink
Merge branch 'main' into table-cols
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 authored Dec 11, 2024
2 parents 909565c + a8cce1c commit c209e33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
13 changes: 12 additions & 1 deletion table/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func (o Options) Run() error {

transformer := unicode.BOMOverride(encoding.Nop.NewDecoder())
reader := csv.NewReader(transform.NewReader(input, transformer))
reader.LazyQuotes = o.LazyQuotes
reader.FieldsPerRecord = o.FieldsPerRecord
separatorRunes := []rune(o.Separator)
if len(separatorRunes) != 1 {
return fmt.Errorf("separator must be single character")
Expand Down Expand Up @@ -95,7 +97,16 @@ func (o Options) Run() error {
data[row] = append(data[row], "")
}

rows = append(rows, table.Row(data[row]))
for i, col := range row {

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

cannot range over row (variable of type int)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint-soft

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint-soft

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

cannot range over row (variable of type int)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

cannot range over row (variable of type int)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

cannot range over row (variable of type int)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint-soft

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / lint-soft

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)) (typecheck)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / snapshot / snapshot

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)

Check failure on line 100 in table/command.go

View workflow job for this annotation

GitHub Actions / snapshot / snapshot

cannot range over row (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)
if len(o.Widths) == 0 {
width := lipgloss.Width(col)
if width > columns[i].Width {
columns[i].Width = width
}
}
}

rows = append(rows, table.Row(data[row]))
}

if o.Print {
Expand Down
18 changes: 10 additions & 8 deletions table/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (

// Options is the customization options for the table command.
type Options struct {
Separator string `short:"s" help:"Row separator" default:","`
Columns []string `short:"c" help:"Column names"`
Widths []int `short:"w" help:"Column widths"`
Height int `help:"Table height" default:"0"`
Print bool `short:"p" help:"static print" default:"false"`
File string `short:"f" help:"file path" default:""`
Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"`
ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"`
Separator string `short:"s" help:"Row separator" default:","`
Columns []string `short:"c" help:"Column names"`
Widths []int `short:"w" help:"Column widths"`
Height int `help:"Table height" default:"0"`
Print bool `short:"p" help:"static print" default:"false"`
File string `short:"f" help:"file path" default:""`
Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"`
ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"`
LazyQuotes bool `help:"If LazyQuotes is true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field" default:"false" env:"GUM_TABLE_LAZY_QUOTES"`
FieldsPerRecord int `help:"Sets the number of expected fields per record" default:"0" env:"GUM_TABLE_FIELDS_PER_RECORD"`

BorderStyle style.Styles `embed:"" prefix:"border." envprefix:"GUM_TABLE_BORDER_"`
CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"`
Expand Down

0 comments on commit c209e33

Please sign in to comment.