MCPcopy Create free account
hub / github.com/docker/docker-language-server / NewRootCmd

Function NewRootCmd

internal/pkg/cli/cli.go:27–50  ·  view source on GitHub ↗

Creates a new RootCmd params: commandName: what to call the base command in examples (e.g., "docker-language-server")

(commandName string)

Source from the content-addressed store, hash-verified

25//
26// commandName: what to call the base command in examples (e.g., "docker-language-server")
27func NewRootCmd(commandName string) *RootCmd {
28 cmd := RootCmd{
29 Command: &cobra.Command{
30 Use: commandName,
31 Short: "Language server for Docker",
32 Version: metadata.Version,
33 },
34 }
35
36 cmd.PersistentFlags().BoolVar(&cmd.debug, "debug", false, "Enable debug logging")
37 cmd.PersistentFlags().BoolVar(&cmd.verbose, "verbose", false, "Enable verbose logging")
38
39 cmd.PersistentPreRun = func(cc *cobra.Command, args []string) {
40 if cmd.debug {
41 logLevel.Set(slog.LevelDebug)
42 } else if cmd.verbose {
43 logLevel.Set(slog.LevelInfo)
44 }
45 }
46
47 cmd.AddCommand(newStartCmd(commandName).Command)
48
49 return &cmd
50}
51
52func Execute() {
53 logLevel.Set(slog.LevelError)

Callers 1

ExecuteFunction · 0.85

Calls 1

newStartCmdFunction · 0.85

Tested by

no test coverage detected