Fix V result redefinition and Crystal nil type error
- V: Rename result variables in cmd_key to avoid redefinition (xdg_result, mac_result, win_result) - Crystal: Fix Bool | Nil type by explicitly checking stdout.nil? before string check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9329d9365f
commit
a46bf88a3e
2 changed files with 8 additions and 7 deletions
|
|
@ -107,7 +107,8 @@ else
|
|||
response = HTTP::Client.post(url, headers: headers, body: body)
|
||||
result = JSON.parse(response.body)
|
||||
|
||||
api_works = result["stdout"]? && result["stdout"].as_s.includes?("Hello from test")
|
||||
stdout = result["stdout"]?
|
||||
api_works = !stdout.nil? && stdout.as_s.includes?("Hello from test")
|
||||
print_test("API endpoint reachable and functional", api_works)
|
||||
rescue ex
|
||||
print_test("API endpoint reachable and functional", false)
|
||||
|
|
|
|||
12
un.v
12
un.v
|
|
@ -179,19 +179,19 @@ fn cmd_key(extend bool, api_key string) {
|
|||
|
||||
// Try xdg-open (Linux), open (macOS), or start (Windows)
|
||||
mut opened := false
|
||||
result := os.execute('xdg-open "${url}"')
|
||||
if result.exit_code == 0 {
|
||||
xdg_result := os.execute('xdg-open "${url}"')
|
||||
if xdg_result.exit_code == 0 {
|
||||
opened = true
|
||||
}
|
||||
if !opened {
|
||||
result2 := os.execute('open "${url}"')
|
||||
if result2.exit_code == 0 {
|
||||
mac_result := os.execute('open "${url}"')
|
||||
if mac_result.exit_code == 0 {
|
||||
opened = true
|
||||
}
|
||||
}
|
||||
if !opened {
|
||||
result3 := os.execute('cmd /c start "${url}"')
|
||||
if result3.exit_code != 0 {
|
||||
win_result := os.execute('cmd /c start "${url}"')
|
||||
if win_result.exit_code != 0 {
|
||||
eprintln('${red}Error: Could not open browser${reset}')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue