gitee.com/mirrors/gauge@v1.0.6/cmd/validate.go (about)

     1  // Copyright 2015 ThoughtWorks, Inc.
     2  
     3  // This file is part of Gauge.
     4  
     5  // Gauge is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  
    10  // Gauge is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU General Public License for more details.
    14  
    15  // You should have received a copy of the GNU General Public License
    16  // along with Gauge.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package cmd
    19  
    20  import (
    21  	"github.com/getgauge/gauge/config"
    22  	"github.com/getgauge/gauge/validation"
    23  	"github.com/spf13/cobra"
    24  )
    25  
    26  const (
    27  	hideSuggestionDefault = false
    28  	hideSuggestionName    = "hide-suggestion"
    29  )
    30  
    31  var (
    32  	validateCmd = &cobra.Command{
    33  		Use:     "validate [flags] [args]",
    34  		Short:   "Check for validation and parse errors",
    35  		Long:    `Check for validation and parse errors.`,
    36  		Example: "  gauge validate specs/",
    37  		Run: func(cmd *cobra.Command, args []string) {
    38  			loadEnvAndReinitLogger(cmd)
    39  			validation.HideSuggestion = hideSuggestion
    40  			if err := config.SetProjectRoot(args); err != nil {
    41  				exit(err, cmd.UsageString())
    42  			}
    43  			installMissingPlugins(installPlugins, true)
    44  			validation.Validate(args)
    45  		},
    46  		DisableAutoGenTag: true,
    47  	}
    48  	hideSuggestion bool
    49  )
    50  
    51  func init() {
    52  	GaugeCmd.AddCommand(validateCmd)
    53  	validateCmd.Flags().BoolVarP(&hideSuggestion, "hide-suggestion", "", false, "Prints a step implementation stub for every unimplemented step")
    54  }