boilerplate

package
v0.0.0-...-660345a Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Copyright <2023> Nik Ogura <nik.ogura@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright <2023> Nik Ogura <nik.ogura@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright <2023> Nik Ogura <nik.ogura@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright <2023> Nik Ogura <nik.ogura@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright <2023> Nik Ogura <nik.ogura@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const VERSION = "3.6.0"

Variables

This section is empty.

Functions

func CobraCliToolParamsFromPrompts

func CobraCliToolParamsFromPrompts(params *CobraCliToolParams, r io.Reader) (err error)

func GetCobraCliToolParamsPromptMessaging

func GetCobraCliToolParamsPromptMessaging() map[ParamPrompt]Prompt

func GetProjectFs

func GetProjectFs(projType string) (embed.FS, string, error)

GetProjectFs Gets the embedded file system for the project of this type.

func IsValidProjectType

func IsValidProjectType(v string) bool

IsValidProjectType Returns true or false depending on whether the project is a supported type.

func PromptForInput

func PromptForInput(p Prompt) (data string, err error)

func ValidProjectTypes

func ValidProjectTypes() []string

ValidProjectTypes Lists the valid project types.

Types

type CobraCliToolParams

type CobraCliToolParams struct {
	ProjectName      string
	ProjectPackage   string
	ProjectShortDesc string
	ProjectLongDesc  string
	MaintainerName   string
	MaintainerEmail  string
	GolangVersion    string
	DbtRepo          string
	ProjectVersion   string
}

func (CobraCliToolParams) AsMap

func (cp CobraCliToolParams) AsMap() (output map[string]interface{}, err error)

func (*CobraCliToolParams) Values

func (cp *CobraCliToolParams) Values() map[ParamPrompt]*string

type FilePath

type FilePath struct {
	Path      string
	Name      string
	TemplPath string
	TemplName string
	IsDir     bool
}

type ParamPrompt

type ParamPrompt string
const (
	GoVersion           ParamPrompt = "GolangVersion"
	DockerRegistry      ParamPrompt = "DockerRegistry"
	DockerProject       ParamPrompt = "DockerProject"
	ProjName            ParamPrompt = "ProjectName"
	ProjPkgName         ParamPrompt = "ProjectPackage"
	ProjEnvPrefix       ParamPrompt = "EnvPrefix"
	ProjShortDesc       ParamPrompt = "ProjectShortDesc"
	ProjLongDesc        ParamPrompt = "ProjectLongDesc"
	ProjMaintainerName  ParamPrompt = "MaintainerName"
	ProjMaintainerEmail ParamPrompt = "MaintainerEmail"
	ServerDefPort       ParamPrompt = "DefaultServerPort"
	ServerShortDesc     ParamPrompt = "ServerShortDesc"
	ServerLongDesc      ParamPrompt = "ServerLongDesc"
	OwnerName           ParamPrompt = "OwnerName"
	OwnerEmail          ParamPrompt = "OwnerEmail"
	DbtRepo             ParamPrompt = "DbtRepo"
	ProjectVersion      ParamPrompt = "ProjectVersion"
)

func (ParamPrompt) String

func (p ParamPrompt) String() string

type Prompt

type Prompt struct {
	From         io.Reader
	PromptMsg    string
	Desc         string
	InputFailMsg string
	DefaultValue string
	Validations  []PromptValidation
}

type PromptValidation

type PromptValidation struct {
	IsValid    func(val string) bool
	InvalidMsg string
}

type PromptValues

type PromptValues interface {
	Values() map[ParamPrompt]*string
	AsMap() (data map[string]interface{}, err error)
}

func PromptsForProject

func PromptsForProject(proj string) (data PromptValues, err error)

type TmplWriter

type TmplWriter struct {
	OutFs     afero.Fs
	TemplFs   embed.FS
	FilePaths []FilePath
	ProjDir   string
	TmplVals  map[string]interface{}
}

func NewTmplWriter

func NewTmplWriter(outFs afero.Fs, projType string, vals map[string]interface{}) (TmplWriter, error)

func (TmplWriter) BuildProject

func (w TmplWriter) BuildProject(destDir string) error

func (TmplWriter) CreateAllFilePathsAtRoot

func (w TmplWriter) CreateAllFilePathsAtRoot(root string) error

func (TmplWriter) CreatePath

func (w TmplWriter) CreatePath(root, file string) error

func (TmplWriter) GetFilePaths

func (w TmplWriter) GetFilePaths(root string) ([]FilePath, error)

func (TmplWriter) ResolveAllPathTemplates

func (w TmplWriter) ResolveAllPathTemplates() error

func (TmplWriter) ResolveFileTemplateData

func (w TmplWriter) ResolveFileTemplateData(fp FilePath) (*bytes.Buffer, error)

func (TmplWriter) ResolveTemplateVars

func (w TmplWriter) ResolveTemplateVars(str string) (*bytes.Buffer, error)

func (TmplWriter) WriteAllDestFileTemplateData

func (w TmplWriter) WriteAllDestFileTemplateData(destDir string) error

func (TmplWriter) WriteFileTemplateData

func (w TmplWriter) WriteFileTemplateData(fp FilePath, destDir string) error

Jump to

Keyboard shortcuts

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