github.com/getgauge/gauge@v1.6.9/cmd/validate.go (about) 1 /*---------------------------------------------------------------- 2 * Copyright (c) ThoughtWorks, Inc. 3 * Licensed under the Apache License, Version 2.0 4 * See LICENSE in the project root for license information. 5 *----------------------------------------------------------------*/ 6 7 package cmd 8 9 import ( 10 "github.com/getgauge/gauge/config" 11 "github.com/getgauge/gauge/validation" 12 "github.com/spf13/cobra" 13 ) 14 15 const ( 16 hideSuggestionDefault = false 17 hideSuggestionName = "hide-suggestion" 18 ) 19 20 var ( 21 validateCmd = &cobra.Command{ 22 Use: "validate [flags] [args]", 23 Short: "Check for validation and parse errors", 24 Long: `Check for validation and parse errors.`, 25 Example: ` gauge validate specs/ 26 gauge validate --env test specs/`, 27 Run: func(cmd *cobra.Command, args []string) { 28 validation.HideSuggestion = hideSuggestion 29 if err := config.SetProjectRoot(args); err != nil { 30 exit(err, cmd.UsageString()) 31 } 32 loadEnvAndReinitLogger(cmd) 33 installMissingPlugins(installPlugins, true) 34 validation.Validate(args) 35 }, 36 DisableAutoGenTag: true, 37 } 38 hideSuggestion bool 39 ) 40 41 func init() { 42 GaugeCmd.AddCommand(validateCmd) 43 flags := validateCmd.Flags() 44 flags.BoolVarP(&hideSuggestion, "hide-suggestion", "", false, "Prints a step implementation stub for every unimplemented step") 45 flags.StringVarP(&environment, environmentName, "e", environmentDefault, "Specifies the environment to use") 46 }