<commit_before>package main

import (
	"fmt"
	"os"

	"github.com/magefile/mage/sh"
	"github.com/pkg/errors"

	"github.com/gilcrest/diy-go-api/command"
)

// NewKey generates a new encryption key,
// example: mage -v newkey
func NewKey() {
	command.NewEncryptionKey()
}

// CueGenerateConfig generates configuration files for the given environment,
// example: mage -v cueGenerateConfig local.
// The files are run through cue vet to ensure they are acceptable given
// the schema and are then run through cue "fmt" to format the files
//
// Acceptable environment values are: local, staging, production
func CueGenerateConfig(env string) (err error) {

	var paths command.ConfigCueFilePaths
	paths, err = command.CUEPaths(command.ParseEnv(env))
	if err != nil {
		return err
	}

	// Vet input files
	vetArgs := []string{"vet"}
	for _, path := range paths.Input {
		vetArgs = append(vetArgs, path)
	}
	err = sh.Run("cue", vetArgs...)
	if err != nil {
		return err
	}

	// format input files
	fmtArgs := []string{"fmt"}
	for _, path := range paths.Input {
		fmtArgs = append(fmtArgs, path)
	}
	err = sh.Run("cue", fmtArgs...)
	if err != nil {
		return err
	}

	// Export output files
	exportArgs := []string{"export"}
	for _, path := range paths.Input {
		exportArgs = append(exportArgs, path)
	}
	exportArgs = append(exportArgs, "--force", "--out", "json", "--outfile", paths.Output)

	err = sh.Run("cue", exportArgs...)
	if err != nil {
		return err
	}

	return nil
}

// CueGenerateGenesisConfig generates the Genesis configuration file,
// example: mage -v cueGenerateGenesisConfig.
// The files are run through cue vet to ensure they are acceptable given
// the schema and are then run through cue "fmt" to format the files
func CueGenerateGenesisConfig() (err error) {

	paths := command.CUEGenesisPaths()

	// Vet input files
	vetArgs := []string{"vet"}
	for _, path := range paths.Input {
		vetArgs = append(vetArgs, path)
	}
	err = sh.Run("cue", vetArgs...)
	if err != nil {
		return err
	}

	// format input files
	fmtArgs := []string{"fmt"}
	for _, path := range paths.Input {
		fmtArgs = append(fmtArgs, path)
	}
	err = sh.Run("cue", fmtArgs...)
	if err != nil {
		return err
	}

	// Export output files
	exportArgs := []string{"export"}
	for _, path := range paths.Input {
		exportArgs = append(exportArgs, path)
	}
	exportArgs = append(exportArgs, "--force", "--out", "json", "--outfile", paths.Output)

	err = sh.Run("cue", exportArgs...)
	if err != nil {
		return err
	}

	return nil
}<commit_msg>Expand slice instead of loop<commit_after>package main

import (
	"fmt"
	"os"

	"github.com/magefile/mage/sh"
	"github.com/pkg/errors"

	"github.com/gilcrest/diy-go-api/command"
)

// NewKey generates a new encryption key,
// example: mage -v newkey
func NewKey() {
	command.NewEncryptionKey()
}

// CueGenerateConfig generates configuration files for the given environment,
// example: mage -v cueGenerateConfig local.
// The files are run through cue vet to ensure they are acceptable given
// the schema and are then run through cue "fmt" to format the files
//
// Acceptable environment values are: local, staging, production
func CueGenerateConfig(env string) (err error) {

	var paths command.ConfigCueFilePaths
	paths, err = command.CUEPaths(command.ParseEnv(env))
	if err != nil {
		return err
	}

	// Vet input files
	vetArgs := []string{"vet"}
	vetArgs = append(vetArgs, paths.Input...)
	err = sh.Run("cue", vetArgs...)
	if err != nil {
		return err
	}

	// format input files
	fmtArgs := []string{"fmt"}
	fmtArgs = append(fmtArgs, paths.Input...)
	err = sh.Run("cue", fmtArgs...)
	if err != nil {
		return err
	}

	// Export output files
	exportArgs := []string{"export"}
	exportArgs = append(exportArgs, paths.Input...)
	exportArgs = append(exportArgs, "--force", "--out", "json", "--outfile", paths.Output)

	err = sh.Run("cue", exportArgs...)
	if err != nil {
		return err
	}

	return nil
}

// CueGenerateGenesisConfig generates the Genesis configuration file,
// example: mage -v cueGenerateGenesisConfig.
// The files are run through cue vet to ensure they are acceptable given
// the schema and are then run through cue "fmt" to format the files
func CueGenerateGenesisConfig() (err error) {

	paths := command.CUEGenesisPaths()

	// Vet input files
	vetArgs := []string{"vet"}
	vetArgs = append(vetArgs, paths.Input...)
	err = sh.Run("cue", vetArgs...)
	if err != nil {
		return err
	}

	// format input files
	fmtArgs := []string{"fmt"}
	fmtArgs = append(fmtArgs, paths.Input...)
	err = sh.Run("cue", fmtArgs...)
	if err != nil {
		return err
	}

	// Export output files
	exportArgs := []string{"export"}
	exportArgs = append(exportArgs, paths.Input...)
	exportArgs = append(exportArgs, "--force", "--out", "json", "--outfile", paths.Output)

	err = sh.Run("cue", exportArgs...)
	if err != nil {
		return err
	}

	return nil
}
{'fraction_non_alphanumeric': 0.1445336627547869, 'fraction_numerical': 0.0, 'mean_word_length': 3.5190697674418603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5356742', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1555, 'n_words': 506}