vgo - trim some uneeded data from struct

This commit is contained in:
jharshman 2019-01-30 01:33:04 -08:00 committed by Steve Francia
parent c7ac101cf8
commit 732e4db0d4
2 changed files with 15 additions and 6 deletions

View file

@ -16,7 +16,6 @@ package cmd
import (
"fmt"
"os"
"path"
"unicode"
"github.com/spf13/cobra"
@ -60,8 +59,8 @@ Example: cobra add server -> resulting in a new cmd/server.go`,
CmdParent: parentName,
Project: &Project{
AbsolutePath: fmt.Sprintf("%s/cmd", wd),
AppName: path.Base(packageName),
PkgName: packageName,
//AppName: path.Base(packageName),
//PkgName: packageName,
Legal: getLicense(),
Copyright: copyrightLine(),
},

View file

@ -91,7 +91,17 @@ func (p *Project) createLicenseFile() error {
}
func (c *Command) Create() error {
return nil
cmdFile, err := os.Create(fmt.Sprintf("%s/cmd/%s.go", c.Project.AbsolutePath, c.CmdName))
if err != nil {
return err
}
defer cmdFile.Close()
commandTemplate := template.Must(template.New("sub").Parse(string(tpl.AddCommandTemplate())))
err = commandTemplate.Execute(cmdFile, c.Project.AbsolutePath)
if err != nil {
return err
}
}
// NewProject returns Project with specified project name.