<commit_before>// Package generation is a runner of subcommands
// related to code generation.
package generation

import (
	"github.com/anonx/sunplate/command"
	"github.com/anonx/sunplate/generation/handlers"
	"github.com/anonx/sunplate/generation/listing"
	"github.com/anonx/sunplate/log"
)

// Handler is an instance of generate subcommand.
var Handler = command.Handler{
	Name:  "generate",
	Info:  `automatic generation of golang code (for use with "go generate")`,
	Usage: "generate {command} [arguments]",
	Desc: `The commands are:
	handlers    generate golang handler functions for a controllers package
	listing     generate a map of file names and paths found in a requested directory

Possible arguments include:
	--input     a path to directory that should be scanned
	--output    a directory where to save generated .go files
	--package   name of the package that should be created

All paths are expected to be relative to the root of your project.

If no arguments are received the default values will be used:
	generate handlers --input ./controllers --output ./assets/handlers --package handlers
	generate listing --input ./views --output ./assets/views --package views
`,

	Main: start,
}

// start is an entry point of generate command.
func start(action string, params command.Data) {
	switch params[action] {
	case "handler", "handlers":
		handlers.Start(params)
	case "listing":
		listing.Start(params)
	default:
		log.Error.Panicf(errMsg, params[action], action)
	}
}

var errMsg = `I do not know how to generate "%s".
Run "sunplate help %s" for more information.
`<commit_msg>Added views instead of listing to generation<commit_after>// Package generation is a runner of subcommands
// related to code generation.
package generation

import (
	"github.com/anonx/sunplate/command"
	"github.com/anonx/sunplate/generation/handlers"
	"github.com/anonx/sunplate/generation/listing"
	"github.com/anonx/sunplate/generation/views"
	"github.com/anonx/sunplate/log"
)

// Handler is an instance of generate subcommand.
var Handler = command.Handler{
	Name:  "generate",
	Info:  `automatic generation of golang code (for use with "go generate")`,
	Usage: "generate {command} [arguments]",
	Desc: `The commands are:
	handlers    generate golang handler functions for a controllers package
	listing     generate a map of file names and paths found in a requested directory

Possible arguments include:
	--input     a path to directory that should be scanned
	--output    a directory where to save generated .go files
	--package   name of the package that should be created

All paths are expected to be relative to the root of your project.

If no arguments are received the default values will be used:
	generate handlers --input ./controllers --output ./assets/handlers --package handlers
	generate listing --input ./views --output ./assets/views --package views
`,

	Main: start,
}

// start is an entry point of generate command.
func start(action string, params command.Data) {
	switch params[action] {
	case "handler", "handlers":
		handlers.Start(params)
	case "listing":
		listing.Start(params)
	case "view", "views":
		views.Start(params)
	default:
		log.Error.Panicf(errMsg, params[action], action)
	}
}

var errMsg = `I do not know how to generate "%s".
Run "sunplate help %s" for more information.
`
{'fraction_non_alphanumeric': 0.09512341962673089, 'fraction_numerical': 0.0, 'mean_word_length': 4.004518072289157, 'pattern_counts': {'":': 5, '<': 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': '628181', 'n_tokens_mistral': 986, 'n_tokens_neox': 936, 'n_words': 387}