models

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	TEMPLATE_PATH        = "./templates"
	FILE_TO_MOVE_PATH    = "./templates/files"
	LOCALRUN_RESULT_PATH = "./tests/tempFiles"

	GITIGNORE_FILE    = ".gitignore"
	DOCKERIGNORE_FILE = ".dockerignore"
	MAIN_GO_FILE      = "main.go"
	MAKEFILE          = "Makefile"
	ENVFILE           = ".env"
)
View Source
const (
	FromCli = iota + 1
	FromConfig
	FromSurvey
)
View Source
const FILEMODE fs.FileMode = 0755

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	DataToAdd    []string
	Constructor  any
	Data         any
	Name         string
	TemplatePath string
	Filename     string
	Filepath     string
	IsTemplate   bool
}

func NewDocument

func NewDocument(name, filename, templatePath string, constructor any, isTemplate bool, dataToAdd []string) *Document

func (*Document) FullDocPath

func (t *Document) FullDocPath() string

FullDocPath return the full path with the document name.

func (*Document) FullFilePath

func (t *Document) FullFilePath() string

FullFilePath returns the full path with the result file name.

type Folder

type Folder struct {
	Name        string
	Permissions fs.FileMode
}

func NewFolder

func NewFolder(name string, perm ...uint32) *Folder

type GlobalConfig

type GlobalConfig struct {
	Skip       []string `yaml:"skip" json:"skip" toml:"skip"`
	Author     string   `yaml:"author" json:"author" toml:"author"`
	Prefix     string   `yaml:"prefix" json:"prefix" toml:"prefix"`
	InitGit    bool     `yaml:"git" json:"git" toml:"git"`
	InitVSCode bool     `yaml:"vscode" json:"vscode" toml:"vscode"`
}

func NewGlobalConfig added in v1.0.5

func NewGlobalConfig(author, prefix string, skip []string, initGit, initVSCode bool) *GlobalConfig

func (*GlobalConfig) Show

func (g *GlobalConfig) Show()

Show writes GlobalConfig info to standart output.

Example
conf := getTestGlobalConfig()
conf.Show()
Output:

func (*GlobalConfig) ShowString

func (g *GlobalConfig) ShowString() string

ShowString returns output string for GlobalConfig.

func (*GlobalConfig) ValidatePrefix added in v1.0.8

func (g *GlobalConfig) ValidatePrefix()

type ProjectInfo

type ProjectInfo struct {
	EmbedFiles      embed.FS
	Documents       []*Document
	Folders         []*Folder
	FilesToGenerate map[string]*Document
	FilesToSkip     []string
	FoldersToSkip   []string
	PackageName     string
	MainFolder      string
	Author          string
	Description     string
	Path            string
	InitGit         bool
	InitVSCode      bool
}

ProjectInfo contains all information about the new project to create.

func NewProjectInfo

func NewProjectInfo(setup *Setup) *ProjectInfo

NewProjectInfo constructs a ProjectInfo

func (*ProjectInfo) AddDocuments added in v1.0.6

func (p *ProjectInfo) AddDocuments(templates ...*Document)

AddDocuments appneds Documents to ProjectInfo Documents field.

func (*ProjectInfo) AddFolders

func (p *ProjectInfo) AddFolders(folders ...*Folder)

AddFolders appneds Folder to ProjectInfo Folders field.

func (*ProjectInfo) GetMainFolder added in v1.1.0

func (p *ProjectInfo) GetMainFolder() *Folder

type Setup

type Setup struct {
	Skip            []string
	PackageName     string
	MainFolder      string
	Author          string
	Description     string
	InitGit         bool
	InitVSCode      bool
	IsSetInitGit    bool
	IsSetInitVSCode bool
	From            int
}

func NewSetup

func NewSetup(
	packageName,
	author,
	description string,
	skip []string,
	initGit,
	initVSCode,
	isSetInitGit,
	isSetInitVSCode bool,
	from int,
) *Setup

NewSetup constructs Setup by fields.

func NewSetupFromConfig

func NewSetupFromConfig(conf *GlobalConfig) *Setup

NewSetupFromConfig costructs Setup from ConfigFromFile.

func (*Setup) FilesToSkip

func (s *Setup) FilesToSkip() []string

FilesToSkip gets files from skip objects.

func (*Setup) FoldersToSkip

func (s *Setup) FoldersToSkip() []string

FoldersToSkip gets folders from skip objects.

func (*Setup) Show

func (s *Setup) Show()

Show writes Setup info to standart output.

Example
setup := getTestSetup(true)
setup.Show()
Output:

func (*Setup) ShowString

func (s *Setup) ShowString() string

ShowString returns output string for Setup.

func (*Setup) Update

func (s *Setup) Update(from *Setup)

Update updates Setup fields by another Setup

func (*Setup) ValidatePackageName added in v1.0.8

func (s *Setup) ValidatePackageName(prefix string)

ValidatePackageName adds prefix from global config

type Survey added in v1.0.5

type Survey struct {
	Skip        []string
	PackageName string
	Author      string
	Description string
	Prefix      string
	InitGit     bool
	InitVSCode  bool
}

func (*Survey) ToGlobalConfig added in v1.0.5

func (s *Survey) ToGlobalConfig() *GlobalConfig

func (*Survey) ToSetup added in v1.0.5

func (s *Survey) ToSetup() *Setup

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL