Skip to content

Commit

Permalink
feat: nuv -info and -version should only report version and exit
Browse files Browse the repository at this point in the history
moved the code that checks these arguments before the olaris checks. Should resolve nuvolaris/nuvolaris#361
  • Loading branch information
d4rkstar committed Jun 2, 2024
1 parent f8e2f07 commit e4a8bde
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ func main() {
setupBinPath(tools.NuvCmd)
}

// check if first argument is help, info version: report output and exit
trace("OS args:", os.Args)
args := os.Args

if len(args) > 1 && len(args[1]) > 0 && args[1][0] == '-' {
cmd := args[1][1:]
switch cmd {
case "info":
info()
os.Exit(0)

case "help":
tools.Help()
os.Exit(0)

case "version":
fmt.Println(NuvVersion)
os.Exit(0)

case "v":
fmt.Println(NuvVersion)
os.Exit(0)

}
}

nuvHome, err := homedir.Expand("~/.nuv")
if err != nil {
log.Fatalf("error: %s", err.Error())
Expand Down Expand Up @@ -160,9 +186,6 @@ func main() {

// first argument with prefix "-" is an embedded tool
// using "-" or "--" or "-task" invokes embedded task
trace("OS args:", os.Args)
args := os.Args

if len(args) > 1 && len(args[1]) > 0 && args[1][0] == '-' {
cmd := args[1][1:]
if cmd == "" || cmd == "-" || cmd == "task" {
Expand All @@ -174,16 +197,6 @@ func main() {
}

switch cmd {
case "version":
fmt.Println(NuvVersion)
case "v":
fmt.Println(NuvVersion)

case "info":
info()

case "help":
tools.Help()

case "serve":
nuvRootDir := getRootDirOrExit()
Expand Down

0 comments on commit e4a8bde

Please sign in to comment.