diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..40aa7bdc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Run `nvm` - no command - in terminal", + "type": "go", + "request": "launch", + "mode": "auto", + "console": "externalTerminal", + "program": "${workspaceFolder}/src/nvm.go", + "args": [] + }, + { + "name": "Run `nvm` - no command - in debug console", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}/src/nvm.go", + "args": [] + }, + { + "name": "Run `nvm version`", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}/src/nvm.go", + "args": [ + "version" + ] + } + ] +} diff --git a/src/nvm.go b/src/nvm.go index 9bcf5966..04c939e9 100644 --- a/src/nvm.go +++ b/src/nvm.go @@ -70,9 +70,19 @@ func main() { detail := "" procarch := arch.Validate(env.arch) - if !isTerminal() { - alert("NVM for Windows should be run from a terminal such as CMD or PowerShell.", "Terminal Only") - os.Exit(0) + // When we don't have any args (the command `nvm` was run by itself): + // + // If it's not a terminal (i.e., clicked `nvm.exe`), pop up a warning; + // Otherwise, just show the help screen. + // + if len(args) < 2 { + if !isTerminal() { + alert("NVM for Windows should be run from a terminal such as CMD or PowerShell. If you are currently in a terminal, try running `nvm help`.", "Terminal Only") + os.Exit(0) + } + + help() + return } // Capture any additional arguments