Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuv -info and -version should only report version and exit #116

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,35 @@ func main() {
log.Fatalf("error: %s", err.Error())
}

setupTmp()
setNuvPwdEnv()
setNuvRootPluginEnv()

// check if first argument is help, info or 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)
}
}

// Check if olaris exists. If not, run `-update` to auto setup
olarisDir := joinpath(joinpath(nuvHome, getNuvBranch()), "olaris")
if !isDir(olarisDir) {
Expand All @@ -144,9 +173,6 @@ func main() {
}
}

setupTmp()
setNuvPwdEnv()
setNuvRootPluginEnv()
if err := setNuvOlarisHash(olarisDir); err != nil {
warn("unable to set NUV_OLARIS...", err.Error())
}
Expand All @@ -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
Loading