Skip to content

Commit 8dc9f84

Browse files
Implement REPL-aware token input handling
- Accept that token input may be interpreted as Julia code - Automatically detect when token becomes a global variable (github_pat_*, ghp_*) - Extract token value from Main namespace if it was interpreted as code - Provide clear user guidance about REPL behavior - Fallback to additional input attempts if needed - More robust than trying to prevent REPL interpretation Handles the case where pasting github_pat_... creates a Julia variable instead of being treated as string input. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d6af1e8 commit 8dc9f84

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

lib/LinearSolveAutotune/src/telemetry.jl

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,52 @@ function setup_github_authentication()
3232
println(" • Repository access: 'Public Repositories (read-only)'")
3333
println("4️⃣ Click 'Generate token' and copy it")
3434
println()
35-
println("🔑 Paste your GitHub token here (just the token, not as Julia code):")
35+
println("🔑 Paste your GitHub token here:")
36+
println(" (If it shows julia> prompt, just paste the token there and press Enter)")
3637
print("Token: ")
3738
flush(stdout)
3839

39-
# Get token input with better REPL handling
40+
# Get token input - handle both direct input and REPL interpretation
4041
token = ""
4142
try
4243
sleep(0.1) # Small delay for I/O stability
43-
token = String(strip(readline())) # Convert to String explicitly
44+
input_line = String(strip(readline()))
45+
46+
# If we got direct input, use it
47+
if !isempty(input_line)
48+
token = input_line
49+
else
50+
# Check if token was interpreted as Julia code and became a variable
51+
# Look for common GitHub token patterns in global variables
52+
println("🔍 Looking for token that may have been interpreted as Julia code...")
53+
for name in names(Main, all=true)
54+
if startswith(string(name), "github_pat_") || startswith(string(name), "ghp_")
55+
try
56+
value = getfield(Main, name)
57+
if isa(value, AbstractString) && length(value) > 20
58+
println("✅ Found token variable: $(name)")
59+
token = String(value)
60+
break
61+
end
62+
catch
63+
continue
64+
end
65+
end
66+
end
67+
68+
# If still no token, try one more direct input
69+
if isempty(token)
70+
println("💡 Please paste your token again (make sure to press Enter after):")
71+
print("Token: ")
72+
flush(stdout)
73+
sleep(0.1)
74+
token = String(strip(readline()))
75+
end
76+
end
77+
4478
catch e
4579
println("❌ Input error: $e")
46-
println("💡 Make sure to paste the token as a string, not Julia code")
80+
println("💡 No worries - this sometimes happens with token input")
4781
continue
4882
end
4983

0 commit comments

Comments
 (0)