mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
backwards conditional logic -_-
This commit is contained in:
parent
22a124de4a
commit
28dd097db8
1 changed files with 4 additions and 4 deletions
|
@ -88,18 +88,18 @@ func initializeProject(project *Project) {
|
|||
} else if !isEmpty(project.AbsPath()) && !force { // If path exists and is not empty don't use it
|
||||
er("Cobra will not create a new project in a non empty directory: " + project.AbsPath())
|
||||
} else if !isEmpty(project.AbsPath()) && force { // If path exists and force flag is true, use it but check to see if files exist first
|
||||
if !exists(project.AbsPath() + "/" + project.License().Name) {
|
||||
fmt.Println(project.AbsPath() + "/LICENSE.txt exists... Skipping")
|
||||
if !exists(project.AbsPath() + "/" + "LICENSE.txt") {
|
||||
fmt.Println(project.AbsPath() + "/LICENSE.txt does not exist... Creating")
|
||||
createLicenseFile(project.License(), project.AbsPath())
|
||||
}
|
||||
|
||||
if !exists(project.AbsPath() + "/" + "main.go") {
|
||||
fmt.Println(project.AbsPath() + "/main.go exists... Skipping")
|
||||
fmt.Println(project.AbsPath() + "/main.go does not exist... Creating")
|
||||
createMainFile(project)
|
||||
}
|
||||
|
||||
if !exists(project.AbsPath() + "/" + "cmd/root.go") {
|
||||
fmt.Println(project.AbsPath() + "/cmd/root.go exists... Skipping")
|
||||
fmt.Println(project.AbsPath() + "/cmd/root.go does not exist... Creating")
|
||||
createRootCmdFile(project)
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue