Skip to content

Commit

Permalink
Merge pull request #1073 from rsteube/loglevel-style
Browse files Browse the repository at this point in the history
loglevel style
  • Loading branch information
rsteube authored Apr 29, 2022
2 parents 58c6747 + 51df807 commit baa5523
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 18 deletions.
3 changes: 2 additions & 1 deletion completers/code_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/rsteube/carapace-bin/completers/code_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/rsteube/carapace-bin/pkg/util"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -77,7 +78,7 @@ func init() {
return action.ActionExtensionSearch(rootCmd.Flag("category").Value.String())
}),
"locale": os.ActionLocales(),
"log": carapace.ActionValues("critical", "error", "warn", "info", "debug", "trace", "off"),
"log": carapace.ActionValues("critical", "error", "warn", "info", "debug", "trace", "off").StyleF(style.ForLogLevel),
"sync": carapace.ActionValues("on", "off"),
"uninstall-extension": action.ActionExtensions(rootCmd),
"user-data-dir": carapace.ActionDirectories(),
Expand Down
3 changes: 2 additions & 1 deletion completers/consul_completer/cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -85,7 +86,7 @@ func init() {
"config-format": carapace.ActionValues("json", "hcl"),
"data-dir": carapace.ActionDirectories(),
"log-file": carapace.ActionFiles(),
"log-level": carapace.ActionValues("trace", "debug", "info", "warn", "err"),
"log-level": carapace.ActionValues("trace", "debug", "info", "warn", "err").StyleF(style.ForLogLevel),
"pid-file": carapace.ActionFiles(),
"ui-dir": carapace.ActionDirectories(),
})
Expand Down
3 changes: 2 additions & 1 deletion completers/consul_completer/cmd/connect_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/consul_completer/cmd/action"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -32,7 +33,7 @@ func init() {

carapace.Gen(connect_proxyCmd).FlagCompletion(carapace.ActionMap{
// TODO flag completion
"log-level": carapace.ActionValues("trace", "debug", "info", "warn", "err"),
"log-level": carapace.ActionValues("trace", "debug", "info", "warn", "err").StyleF(style.ForLogLevel),
"sidecar-for": action.ActionServices(connect_proxyCmd), // TODO local service
})
}
3 changes: 2 additions & 1 deletion completers/consul_completer/cmd/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand All @@ -20,6 +21,6 @@ func init() {
rootCmd.AddCommand(monitorCmd)

carapace.Gen(monitorCmd).FlagCompletion(carapace.ActionMap{
"log-level": carapace.ActionValues("trace", "debug", "info", "warn", "err"),
"log-level": carapace.ActionValues("trace", "debug", "info", "warn", "err").StyleF(style.ForLogLevel),
})
}
3 changes: 2 additions & 1 deletion completers/deno_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand All @@ -26,6 +27,6 @@ func init() {
rootCmd.PersistentFlags().Bool("unstable", false, "Enable unstable features and APIs")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"log-level": carapace.ActionValues("debug", "info"),
"log-level": carapace.ActionValues("debug", "info").StyleF(style.ForLogLevel),
})
}
3 changes: 2 additions & 1 deletion completers/docker_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -32,7 +33,7 @@ func init() {

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionFiles(),
"log-level": carapace.ActionValues("debug", "info", "warn", "error", "fatal"),
"log-level": carapace.ActionValues("debug", "info", "warn", "error", "fatal").StyleF(style.ForLogLevel),
"tlscacert": carapace.ActionFiles(),
"tlscert": carapace.ActionFiles(),
"tlskey": carapace.ActionFiles(),
Expand Down
3 changes: 2 additions & 1 deletion completers/dockerd_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -118,7 +119,7 @@ func init() {
"exec-root": carapace.ActionDirectories(),
"group": os.ActionGroups(),
"init-path": carapace.ActionDirectories(),
"log-level": carapace.ActionValues("debug", "info", "warn", "error", "fatal"),
"log-level": carapace.ActionValues("debug", "info", "warn", "error", "fatal").StyleF(style.ForLogLevel).StyleF(style.ForLogLevel),
"pidfile": carapace.ActionFiles(),
"userland-proxy-path": carapace.ActionFiles(),
})
Expand Down
3 changes: 2 additions & 1 deletion completers/kmonad_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand All @@ -23,7 +24,7 @@ func init() {
rootCmd.Flags().StringP("log-level", "l", "", "How much info to print out")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"log-level": carapace.ActionValues("debug", "info", "warn", "error"),
"log-level": carapace.ActionValues("debug", "info", "warn", "error").StyleF(style.ForLogLevel),
})

carapace.Gen(rootCmd).PositionalCompletion(
Expand Down
3 changes: 2 additions & 1 deletion completers/mcomix_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -31,7 +32,7 @@ func init() {
rootCmd.Flags().BoolP("zoom-width", "w", false, "Start the application with zoom set to fit width.")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"W": carapace.ActionValues("all", "debug", "info", "warn", "error"),
"W": carapace.ActionValues("all", "debug", "info", "warn", "error").StyleF(style.ForLogLevel),
})

carapace.Gen(rootCmd).PositionalAnyCompletion(
Expand Down
3 changes: 2 additions & 1 deletion completers/nu_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand All @@ -27,7 +28,7 @@ func init() {
rootCmd.Flags().BoolP("version", "V", false, "Prints version information")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"loglevel": carapace.ActionValues("error", "warn", "info", "debug", "trace"),
"loglevel": carapace.ActionValues("error", "warn", "info", "debug", "trace").StyleF(style.ForLogLevel),
})

carapace.Gen(rootCmd).PositionalCompletion(
Expand Down
3 changes: 2 additions & 1 deletion completers/qmk_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -36,6 +37,6 @@ func init() {
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"config-file": carapace.ActionFiles(),
"log-file": carapace.ActionFiles(),
"log-file-level": carapace.ActionValues("debug", "info", "warning", "error", "critical"),
"log-file-level": carapace.ActionValues("debug", "info", "warning", "error", "critical").StyleF(style.ForLogLevel),
})
}
3 changes: 2 additions & 1 deletion completers/qutebrowser_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -44,7 +45,7 @@ func init() {
"backend": carapace.ActionValues("webkit", "webengine"),
"basedir": carapace.ActionDirectories(),
"config-py": carapace.ActionFiles(),
"loglevel": carapace.ActionValues("critical", "error", "warning", "info", "debug", "vdebug"),
"loglevel": carapace.ActionValues("critical", "error", "warning", "info", "debug", "vdebug").StyleF(style.ForLogLevel),
"target": carapace.ActionValues("auto", "tab", "tab-bg", "tab-silent", "tab-bg-silent", "window"),
})

Expand Down
3 changes: 2 additions & 1 deletion completers/supervisord_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/fs"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -46,7 +47,7 @@ func init() {
"configuration": carapace.ActionFiles(),
"directory": carapace.ActionDirectories(),
"logfile": carapace.ActionFiles(),
"loglevel": carapace.ActionValues("trace", "debug", "info", "warn", "error", "critical"),
"loglevel": carapace.ActionValues("trace", "debug", "info", "warn", "error", "critical").StyleF(style.ForLogLevel),
"pidfile": carapace.ActionFiles(),
"profile_options": carapace.ActionMultiParts(",", func(c carapace.Context) carapace.Action {
return carapace.ActionValues("cumulative", "calls", "callers").Invoke(c).Filter(c.Parts).ToA()
Expand Down
3 changes: 2 additions & 1 deletion completers/traefik_completer/cmd/action/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/rsteube/carapace-bin/pkg/actions/tools/aws"
"github.com/rsteube/carapace-bin/pkg/actions/tools/docker"
"github.com/rsteube/carapace-bin/pkg/actions/tools/jaeger"
"github.com/rsteube/carapace/pkg/style"
)

func ActionParameters() carapace.Action {
Expand Down Expand Up @@ -585,7 +586,7 @@ func flagValues(name string) (acn carapace.Action, ok bool) {
"--tracing.haystack.traceidheadername": carapace.ActionValues(),
"--tracing.instana.localagenthost": carapace.ActionValues(),
"--tracing.instana.localagentport": carapace.ActionValues(),
"--tracing.instana.loglevel": carapace.ActionValues("error", "warn", "info", "debug"),
"--tracing.instana.loglevel": carapace.ActionValues("error", "warn", "info", "debug").StyleF(style.ForLogLevel),
"--tracing.jaeger.collector.endpoint": carapace.ActionValues(),
"--tracing.jaeger.collector.password": carapace.ActionValues(),
"--tracing.jaeger.collector.user": carapace.ActionValues(),
Expand Down
3 changes: 2 additions & 1 deletion completers/zathura_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -40,7 +41,7 @@ func init() {
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"config-dir": carapace.ActionDirectories(),
"data-dir": carapace.ActionDirectories(),
"log-level": carapace.ActionValues("debug", "info", "warning", "error"),
"log-level": carapace.ActionValues("debug", "info", "warning", "error").StyleF(style.ForLogLevel),
"mode": carapace.ActionValues("fullscreen", "presentation"),
"plugins-dir": carapace.ActionDirectories(),
"synctex-pid": os.ActionProcessIds(),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-ps v1.0.0
github.com/pelletier/go-toml v1.9.5
github.com/rsteube/carapace v0.20.0
github.com/rsteube/carapace v0.20.1
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rsteube/carapace v0.20.0 h1:nwHHf7PYUlOOyUTUpSvRZFdQ7DDsQsdZiV96dN53bFo=
github.com/rsteube/carapace v0.20.0/go.mod h1:GgiwpPVhucHNOv0AmtIkxhiEFkCMP5BBRauyQLP0mFY=
github.com/rsteube/carapace v0.20.1 h1:ZnPtEZQGi4vSoco7yLexTvmx9X82jUaOcDScpl3v14M=
github.com/rsteube/carapace v0.20.1/go.mod h1:GgiwpPVhucHNOv0AmtIkxhiEFkCMP5BBRauyQLP0mFY=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
Expand Down

0 comments on commit baa5523

Please sign in to comment.