Skip to content
Open
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
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var (

output = flag.String("output", "", "output fields: "+strings.Join(columnIDs(), ", "))
sortBy = flag.String("sort", "mountpoint", "sort output by: "+strings.Join(columnIDs(), ", "))
reverse = flag.Bool("reverse", false, "reverse sort order")
width = flag.Uint("width", 0, "max output width")
themeOpt = flag.String("theme", defaultThemeName(), "color themes: dark, light, ansi")
styleOpt = flag.String("style", defaultStyleName(), "style: unicode, ascii")
Expand Down Expand Up @@ -356,6 +357,7 @@ func main() {
renderTables(m, filters, TableOptions{
Columns: columns,
SortBy: sortCol,
Reverse: *reverse,
Style: style,
StyleName: *styleOpt,
})
Expand Down
12 changes: 10 additions & 2 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
type TableOptions struct {
Columns []int
SortBy int
Reverse bool
Style table.Style
StyleName string
}
Expand Down Expand Up @@ -432,8 +433,15 @@ func printTable(title string, m []Mount, opts TableOptions) {

// tab.AppendFooter(table.Row{fmt.Sprintf("%d %s", tab.Length(), title)})
sortMode := table.Asc
if opts.SortBy >= 12 {
sortMode = table.AscNumeric
if opts.Reverse {
sortMode = table.Dsc
if opts.SortBy >= 12 {
sortMode = table.DscNumeric
}
} else {
if opts.SortBy >= 12 {
sortMode = table.AscNumeric
}
}

tab.SortBy([]table.SortBy{{Number: opts.SortBy, Mode: sortMode}})
Expand Down