From 844727f185553cfbff08d11877ccfd916bedcf9e Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 13 Oct 2022 11:02:08 -0400 Subject: [PATCH] fix(table): hide extra style flags + fix envprefix --- file/command.go | 8 ++++++++ pager/command.go | 8 ++++++++ table/options.go | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/file/command.go b/file/command.go index 172e77b..16e49b8 100644 --- a/file/command.go +++ b/file/command.go @@ -5,8 +5,10 @@ import ( "os" "path/filepath" + "github.com/alecthomas/kong" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/stack" + "github.com/charmbracelet/gum/style" ) // Run is the interface to picking a file. @@ -56,3 +58,9 @@ func (o Options) Run() error { return nil } + +// BeforeReset hook. Used to unclutter style flags. +func (o Options) BeforeReset(ctx *kong.Context) error { + style.HideFlags(ctx) + return nil +} diff --git a/pager/command.go b/pager/command.go index ec9c1b6..a727a40 100644 --- a/pager/command.go +++ b/pager/command.go @@ -3,9 +3,11 @@ package pager import ( "fmt" + "github.com/alecthomas/kong" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/style" ) // Run provides a shell script interface for the viewport bubble. @@ -39,3 +41,9 @@ func (o Options) Run() error { } return nil } + +// BeforeReset hook. Used to unclutter style flags. +func (o Options) BeforeReset(ctx *kong.Context) error { + style.HideFlags(ctx) + return nil +} diff --git a/table/options.go b/table/options.go index b2112c3..dc692ef 100644 --- a/table/options.go +++ b/table/options.go @@ -8,8 +8,8 @@ type Options struct { Columns []string `short:"c" help:"Column names"` Widths []int `short:"w" help:"Column widths"` Height int `help:"Table height" default:"10"` - CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL"` - HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER"` - SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED"` + CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"` + HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER_"` + SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED_"` File string `short:"f" help:"file path" default:""` }