Skip to content

Commit

Permalink
Format also concepts
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Nestorow <[email protected]>
  • Loading branch information
PiotrNestor committed Jul 3, 2024
1 parent 522443e commit e229ef9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (

var formatCmd = &cobra.Command{
Use: "format [flags] [args]",
Short: "Formats the specified spec files",
Long: `Formats the specified spec files.`,
Short: "Formats the specified spec and/or concept files",
Long: `Formats the specified spec and/or concept files.`,
Example: " gauge format specs/",
Run: func(cmd *cobra.Command, args []string) {
if err := config.SetProjectRoot(args); err != nil {
exit(err, cmd.UsageString())
}
loadEnvAndReinitLogger(cmd)
formatter.FormatSpecFilesIn(getSpecsDir(args)[0])
formatter.FormatConceptFilesIn(getSpecsDir(args)[0])
},
DisableAutoGenTag: true,
}
Expand Down
10 changes: 10 additions & 0 deletions formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,13 @@ func FormatSpecFilesIn(filesLocation string) {
os.Exit(1)
}
}

func FormatConceptFilesIn(filesLocation string) {
conceptFiles := util.FindConceptFiles([]string{filesLocation})
conceptsDictionary := gauge.NewConceptDictionary()
parser.AddConcepts(conceptFiles, conceptsDictionary)
conceptMap := FormatConcepts(conceptsDictionary)
for file, formatted := range conceptMap {
common.SaveFile(file, formatted, true)
}
}
5 changes: 5 additions & 0 deletions util/fileUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ func findConceptFiles(paths []string) []string {
return conceptFiles
}

// Exported (public) function that calls the unexported function
func FindConceptFiles(paths []string) []string {
return findConceptFiles(paths)
}

// GetConceptFiles It returns the list of concept files
// It returns concept files from gauge_concepts_dir if present
// It returns concept files from projectRoot otherwise
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// CurrentGaugeVersion represents the current version of Gauge
var CurrentGaugeVersion = &Version{1, 6, 7}
var CurrentGaugeVersion = &Version{1, 6, 8}

// BuildMetadata represents build information of current release (e.g, nightly build information)
var BuildMetadata = ""
Expand Down

0 comments on commit e229ef9

Please sign in to comment.