fix(table): hide extra style flags + fix envprefix

This commit is contained in:
Maas Lalani 2022-10-13 11:02:08 -04:00
parent 2c66222fd8
commit 844727f185
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
3 changed files with 19 additions and 3 deletions

View file

@ -5,8 +5,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/alecthomas/kong"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/gum/internal/stack" "github.com/charmbracelet/gum/internal/stack"
"github.com/charmbracelet/gum/style"
) )
// Run is the interface to picking a file. // Run is the interface to picking a file.
@ -56,3 +58,9 @@ func (o Options) Run() error {
return nil return nil
} }
// BeforeReset hook. Used to unclutter style flags.
func (o Options) BeforeReset(ctx *kong.Context) error {
style.HideFlags(ctx)
return nil
}

View file

@ -3,9 +3,11 @@ package pager
import ( import (
"fmt" "fmt"
"github.com/alecthomas/kong"
"github.com/charmbracelet/bubbles/viewport" "github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/stdin"
"github.com/charmbracelet/gum/style"
) )
// Run provides a shell script interface for the viewport bubble. // Run provides a shell script interface for the viewport bubble.
@ -39,3 +41,9 @@ func (o Options) Run() error {
} }
return nil return nil
} }
// BeforeReset hook. Used to unclutter style flags.
func (o Options) BeforeReset(ctx *kong.Context) error {
style.HideFlags(ctx)
return nil
}

View file

@ -8,8 +8,8 @@ type Options struct {
Columns []string `short:"c" help:"Column names"` Columns []string `short:"c" help:"Column names"`
Widths []int `short:"w" help:"Column widths"` Widths []int `short:"w" help:"Column widths"`
Height int `help:"Table height" default:"10"` Height int `help:"Table height" default:"10"`
CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL"` CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"`
HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER"` HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER_"`
SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED"` SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED_"`
File string `short:"f" help:"file path" default:""` File string `short:"f" help:"file path" default:""`
} }