mirror of
https://github.com/spf13/cobra
synced 2025-05-05 04:47:22 +00:00
Merge 13e5bcf908
into 6d2dc43606
This commit is contained in:
commit
37d401cc58
1 changed files with 8 additions and 1 deletions
|
@ -83,7 +83,14 @@ func (p *Project) createLicenseFile() error {
|
|||
}
|
||||
|
||||
func (c *Command) Create() error {
|
||||
cmdFile, err := os.Create(fmt.Sprintf("%s/cmd/%s.go", c.AbsolutePath, c.CmdName))
|
||||
fileName := fmt.Sprintf("%s/cmd/%s.go", c.AbsolutePath, c.CmdName)
|
||||
|
||||
// check if Command exists
|
||||
if _, err := os.Stat(fileName); err == nil {
|
||||
return fmt.Errorf("command '%s' already exists", c.CmdName)
|
||||
}
|
||||
|
||||
cmdFile, err := os.Create(fileName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue