Skip to content

Commit

Permalink
validate only command
Browse files Browse the repository at this point in the history
  • Loading branch information
po3rin committed Nov 28, 2020
1 parent d4cc148 commit b3cbeb8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cmd/eskeeper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,36 @@ var rootCmd = &cobra.Command{
},
}

var validate = &cobra.Command{
Use: "validate",
Short: "Validates config",
Run: func(cmd *cobra.Command, args []string) {
k, err := eskeeper.New(
[]string{},
eskeeper.Verbose(true),
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

if terminal.IsTerminal(int(os.Stdin.Fd())) {
fmt.Println("Currently does not support interactive mode")
os.Exit(1)
}

ctx := context.Background()
err = k.Validate(ctx, os.Stdin)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("pass")
},
}

func init() {
rootCmd.AddCommand(validate)
viper.SetEnvPrefix("eskeeper")
viper.AutomaticEnv()

Expand Down

0 comments on commit b3cbeb8

Please sign in to comment.