Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Prefer early return
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jun 20, 2023
1 parent 8a4469f commit cfa3d8d
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions nix-headbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,32 @@ func main() {
log.Fatalf("Failed to get target files: %s", err.Error())
}

if path != "" {
if *printTargetFlag {
fmt.Println(path)
return
}
if *currentFlag {
current, err := getCurrentVersion(path)
if err != nil {
log.Fatalf("Getting the current version has been failed: %s", err.Error())
}
fmt.Println(current)
return
}
last, err := getLastVersion()
if err != nil {
log.Fatalf("Getting the last version has been failed: %s", err.Error())
}
if *lastFlag {
fmt.Println(last)
return
}
err = bump(path, last)
if path == "" {
log.Fatalln("Both default.nix and shell.nix are not found")
}

if *printTargetFlag {
fmt.Println(path)
return
}
if *currentFlag {
current, err := getCurrentVersion(path)
if err != nil {
log.Fatalf("Bumping the version has been failed: %s", err.Error())
log.Fatalf("Getting the current version has been failed: %s", err.Error())
}
} else {
log.Fatalln("Both default.nix and shell.nix are not found")
fmt.Println(current)
return
}
last, err := getLastVersion()
if err != nil {
log.Fatalf("Getting the last version has been failed: %s", err.Error())
}
if *lastFlag {
fmt.Println(last)
return
}
if err = bump(path, last); err != nil {
log.Fatalf("Bumping the version has been failed: %s", err.Error())
}
}

Expand Down

0 comments on commit cfa3d8d

Please sign in to comment.