github.com/getgauge/gauge@v1.6.9/cmd/format.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/formatter"
    12  	"github.com/spf13/cobra"
    13  )
    14  
    15  var formatCmd = &cobra.Command{
    16  	Use:     "format [flags] [args]",
    17  	Short:   "Formats the specified spec files",
    18  	Long:    `Formats the specified spec files.`,
    19  	Example: "  gauge format specs/",
    20  	Run: func(cmd *cobra.Command, args []string) {
    21  		if err := config.SetProjectRoot(args); err != nil {
    22  			exit(err, cmd.UsageString())
    23  		}
    24  		loadEnvAndReinitLogger(cmd)
    25  		formatter.FormatSpecFilesIn(getSpecsDir(args)[0])
    26  	},
    27  	DisableAutoGenTag: true,
    28  }
    29  
    30  func init() {
    31  	GaugeCmd.AddCommand(formatCmd)
    32  }