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

Show terminal warning only when user did not enter arguments. #1120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
16 changes: 13 additions & 3 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down