mirror of
https://github.com/spf13/cobra.git
synced 2024-11-15 09:48:19 -07:00
vgo - generate license
This commit is contained in:
parent
abab9aa52a
commit
5b1685faaa
@ -60,10 +60,39 @@ func (p *Project) Create() error {
|
||||
}
|
||||
|
||||
// create license
|
||||
createLicenseFile(p.Legal, p.AbsolutePath)
|
||||
return nil
|
||||
return createLicenseFile(p.Legal, p.AbsolutePath)
|
||||
}
|
||||
|
||||
func (p *Project) createLicenseFile() error {
|
||||
data := map[string]interface{}{
|
||||
"copyright": copyrightLine(),
|
||||
}
|
||||
licenseFile, err := os.Create(fmt.Sprintf("%s/LICENSE", p.AbsolutePath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
licenseTemplate := template.Must(template.New("license").Parse(p.Legal.Text))
|
||||
return licenseTemplate.Execute(licenseFile, data)
|
||||
}
|
||||
|
||||
//func createLicenseFile(license License, path string) {
|
||||
// data := make(map[string]interface{})
|
||||
// data["copyright"] = copyrightLine()
|
||||
//
|
||||
// // Generate license template from text and data.
|
||||
// text, err := executeTemplate(license.Text, data)
|
||||
// if err != nil {
|
||||
// er(err)
|
||||
// }
|
||||
//
|
||||
// // Write license text to LICENSE file.
|
||||
// err = writeStringToFile(filepath.Join(path, "LICENSE"), text)
|
||||
// if err != nil {
|
||||
// er(err)
|
||||
// }
|
||||
//}
|
||||
|
||||
// NewProject returns Project with specified project name.
|
||||
func NewProject(projectName string) *Project {
|
||||
if projectName == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user