feat: rename flag and variables env to enviroment

This commit is contained in:
Daniel Thomas 2022-02-21 08:17:57 +01:00
parent d11acea542
commit 55d3ab9cd2
2 changed files with 7 additions and 7 deletions

View File

@ -68,14 +68,14 @@ func getContentTypes(CMA *contentful.Contentful, spaceID string) (contentTypes [
return
}
func getData(spaceID, cmaKey, env string, flagContentTypes []string) (
func getData(spaceID, cmaKey, environment string, flagContentTypes []string) (
finalContentTypes []ContentType, locales []Locale, err error,
) {
// Get client
CMA := contentful.NewCMA(cmaKey)
CMA.Debug = false
if env != "" {
CMA.Environment = env
if environment != "" {
CMA.Environment = environment
}
// Get space locales
@ -111,8 +111,8 @@ func getData(spaceID, cmaKey, env string, flagContentTypes []string) (
}
// GenerateAPI calls the generators
func GenerateAPI(dir, packageName, spaceID, cmaKey, env string, flagContentTypes []string) (err error) {
contentTypes, locales, errGetData := getData(spaceID, cmaKey, env, flagContentTypes)
func GenerateAPI(dir, packageName, spaceID, cmaKey, environment string, flagContentTypes []string) (err error) {
contentTypes, locales, errGetData := getData(spaceID, cmaKey, environment, flagContentTypes)
if errGetData != nil {
return errGetData
}

View File

@ -35,7 +35,7 @@ func main() {
// Get parameters from cmd line flags
flagSpaceID := flag.String("spaceid", "", "Contentful space ID")
flagCMAKey := flag.String("cmakey", "", "Contentful CMA key")
flagEnv := flag.String("env", "", "Contentful enviroment")
flagEnvironment := flag.String("environment", "", "Contentful space environment")
flagContentTypes := flag.String("contenttypes", "", "[Optional] Content type IDs to parse, comma separated")
flagVersion := flag.Bool("version", false, "Print version and exit")
flagHelp := flag.Bool("help", false, "Print version and exit")
@ -76,7 +76,7 @@ func main() {
}
}
err = erm.GenerateAPI(filepath.Dir(path), packageName, *flagSpaceID, *flagCMAKey, *flagEnv, flagContentTypesSlice)
err = erm.GenerateAPI(filepath.Dir(path), packageName, *flagSpaceID, *flagCMAKey, *flagEnvironment, flagContentTypesSlice)
if err != nil {
fatal("Something went horribly wrong...", err)
}