Skip to content

Commit 83fa8ca

Browse files
perhammanton.voskresensky
andauthored
fix complition and help
Co-authored-by: anton.voskresensky <anton.voskresensky@flant.com>
1 parent d64b8f3 commit 83fa8ca

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

commands/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"osctl/pkg/config"
66
"osctl/pkg/logging"
7+
"strings"
78

89
"github.com/spf13/cobra"
910
)
@@ -60,6 +61,11 @@ func Execute(version string) error {
6061

6162
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
6263
commandName := cmd.Name()
64+
commandPath := cmd.CommandPath()
65+
if commandName == "completion" || commandName == "help" ||
66+
commandPath == "osctl completion" || strings.HasPrefix(commandPath, "osctl completion") {
67+
return nil
68+
}
6369
if commandName == "osctl" {
6470
if action, _ := cmd.Flags().GetString("action"); action != "" {
6571
return nil

pkg/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ var (
6969
)
7070

7171
func LoadConfig(cmd *cobra.Command, commandName string) error {
72+
if commandName == "completion" || commandName == "help" {
73+
return nil
74+
}
75+
7276
viper.Reset()
7377
viper.SetConfigType("yaml")
7478

0 commit comments

Comments
 (0)