8000 Changed PAGER feature to opt-in by applejag · Pull Request #130 · kubecolor/kubecolor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Changed PAGER feature to opt-in #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2024
Merged
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ Example file (the values shows the default values):
kubectl: kubectl # path to kubectl executable
preset: dark # color theme preset
objFreshThreshold: 0 # ages below this uses theme.data.durationfresh coloring
paging: auto # whether to pipe supported subcommands to a pager ("auto" or "never")
paging: never # whether to pipe supported subcommands to a pager ("auto" or "never")
pager: # the command to use as pager; default uses $PAGER, less, or more

# Color theme options
Expand Down
14 changes: 7 additions & 7 deletions command/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Test_ResolveConfig(t *testing.T) {
name: "no config",
args: []string{"get", "pods"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelUnset,
KubectlCmd: "kubectl",
ObjFreshThreshold: time.Duration(0),
Expand All @@ -33,7 +33,7 @@ func Test_ResolveConfig(t *testing.T) {
name: "plain, light, force",
args: []string{"get", "pods", "--plain", "--light-background", "--force-colors"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelAuto,
KubectlCmd: "kubectl",
ObjFreshThreshold: time.Duration(0),
Expand All @@ -46,7 +46,7 @@ func Test_ResolveConfig(t *testing.T) {
args: []string{"get", "pods", "--plain"},
env: map[string]string{"KUBECTL_COMMAND": "kubectl.1.19"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelNone,
KubectlCmd: "kubectl.1.19",
ObjFreshThreshold: time.Duration(0),
Expand All @@ -59,7 +59,7 @@ func Test_ResolveConfig(t *testing.T) {
args: []string{"get", "pods"},
env: map[string]string{"KUBECOLOR_OBJ_FRESH": "1m"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelUnset,
KubectlCmd: "kubectl",
ObjFreshThreshold: time.Minute,
Expand All @@ -72,7 +72,7 @@ func Test_ResolveConfig(t *testing.T) {
args: []string{"get", "pods"},
env: map[string]string{"KUBECOLOR_LIGHT_BACKGROUND": "true"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelUnset,
KubectlCmd: "kubectl",
Theme: testconfig.LightTheme,
Expand All @@ -84,7 +84,7 @@ func Test_ResolveConfig(t *testing.T) {
args: []string{"get", "pods"},
env: map[string]string{"KUBECOLOR_FORCE_COLORS": "true"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelAuto,
KubectlCmd: "kubectl",
Theme: testconfig.DarkTheme,
Expand All @@ -96,7 +96,7 @@ func Test_ResolveConfig(t *testing.T) {
args: []string{"get", "pods"},
env: map[string]string{"KUBECOLOR_FORCE_COLORS": "truecolor"},
expectedConf: &Config{
Paging: config.PagingAuto,
Paging: config.PagingDefault,
ForceColor: ColorLevelTrueColor,
KubectlCmd: "kubectl",
Theme: testconfig.DarkTheme,
Expand Down
2 changes: 1 addition & 1 deletion command/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Run(args []string, version string) error {
}

switch {
// Skip if special subcommand (e.g "kubectl exec")
// Skip if special subcommand (e.g "kubectl exec")
case !subcommandInfo.SupportsColoring(),
// Skip if explicitly setting --force-colors=none
cfg.ForceColor == ColorLevelNone,
Expand Down
2 changes: 1 addition & 1 deletion config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
],
"title": "Paging mode preference",
"description": "Whether to pipe supported subcommands to a pager (\"auto\" or \"never\")",
"default": "auto"
"default": "never"
},
"preset": {
"type": "string",
Expand Down
1 change: 0 additions & 1 deletion config/color_raw.go
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Config struct {
Preset Preset // Color theme preset
Theme Theme //
Pager string `jsonschema:"example=less -RF,less --RAW-CONTROL-CHARS --quit-if-one-screen,example=more"` // Command to use as pager
Paging Paging `jsonschema:"default=auto"` // Whether to enable paging: "auto" or "never"
Paging Paging `jsonschema:"default=never"` // Whether to enable paging: "auto" or "never"
}

func NewViper() *viper.Viper {
Expand Down
5 changes: 4 additions & 1 deletion config/paging.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const (
)

var (
PagingDefault = PagingAuto
// Due to a thorough and long lasting democratic voting process
// (composed by a wide represenation of one (1) person),
// paging was decided to be opt-in instead of opt-out. :^)
PagingDefault = PagingNever

AllPagingModes []Paging = []Paging{
PagingAuto,
Expand Down
1E0A
4 changes: 2 additions & 2 deletions kubectl/subcommand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
// func TestInspectSubcommandInfo(args []string) (*SubcommandInfo, bool) {
func TestInspectSubcommandInfo(t *testing.T) {
tests := []struct {
args string
expected *SubcommandInfo
args string
expected *SubcommandInfo
}{
{"get pods", &SubcommandInfo{Subcommand: Get}},
{"get pod", &SubcommandInfo{Subcommand: Get}},
Expand Down
0