Skip to content

Commit

Permalink
vgo - trim some uneeded data from struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jharshman authored and spf13 committed Jun 7, 2019
1 parent c7ac101 commit 732e4db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 4 additions & 5 deletions cobra/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package cmd
import (
"fmt"
"os"
"path"
"unicode"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -60,10 +59,10 @@ 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,
Legal: getLicense(),
Copyright: copyrightLine(),
//AppName: path.Base(packageName),
//PkgName: packageName,
Legal: getLicense(),
Copyright: copyrightLine(),
},
}

Expand Down
12 changes: 11 additions & 1 deletion cobra/cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 732e4db

Please sign in to comment.