Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format concept files added #2566

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 23 additions & 0 deletions formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,26 @@ func FormatSpecFilesIn(filesLocation string) {
os.Exit(1)
}
}

func FormatConceptFilesIn(filesLocation string) {
conceptFiles := util.FindConceptFiles([]string{filesLocation})
conceptsDictionary := gauge.NewConceptDictionary()
if _, errs, e := parser.AddConcepts(conceptFiles, conceptsDictionary); len(errs) > 0 {
for _, err := range errs {
logger.Errorf(false, "Concept parse failure: %s %s", conceptFiles[0], err)
}
if e != nil {
logger.Errorf(false, "Concept failure: %s %s", conceptFiles[0], e)
os.Exit(1)
}
}
conceptMap := FormatConcepts(conceptsDictionary)
for file, formatted := range conceptMap {
e := common.SaveFile(file, formatted, true)
if e != nil {
logger.Errorf(false, "Concept file save failure: %s", e)
os.Exit(1)
}

}
}
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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var CurrentGaugeVersion = &Version{1, 6, 8}
var CurrentGaugeVersion = &Version{1, 6, 9}


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