Add key subcommand to remaining 25 implementations
Complete key command across all 42 CLI implementations: - un.go, un.v, un.fs, un.groovy (systems/JVM) - un.dart, un_inception.c, un_deno.ts, un.ps1 (mixed) - un.hs, un.ml, un.clj, un.scm (functional) - un.lisp, un.erl, un.ex, un.f90 (functional/scientific) - un.cob, un.pro, un.forth, un.raku (exotic) - un.m, un.awk (other) - un.js, un.ts, un.pl (fixes to existing) All implementations now support: - key: Validate API key and show status - key --extend: Open browser to renew key
This commit is contained in:
parent
5380af54cb
commit
fa40b3bc78
25 changed files with 1438 additions and 182 deletions
69
un.v
69
un.v
|
|
@ -126,17 +126,22 @@ fn extract_json_string(json string, key string) string {
|
|||
}
|
||||
|
||||
fn cmd_key(extend bool, api_key string) {
|
||||
cmd := "curl -s -X POST '${api_base}/keys/validate' -H 'Content-Type: application/json' -H 'Authorization: Bearer ${api_key}' -d '{}'"
|
||||
cmd := "curl -s -X POST '${portal_base}/keys/validate' -H 'Content-Type: application/json' -H 'Authorization: Bearer ${api_key}' -d '{}'"
|
||||
result := exec_curl(cmd)
|
||||
|
||||
status := extract_json_string(result, 'status')
|
||||
public_key := extract_json_string(result, 'public_key')
|
||||
tier := extract_json_string(result, 'tier')
|
||||
expired_at := extract_json_string(result, 'expired_at')
|
||||
status := extract_json_string(result, 'status')
|
||||
expires_at := extract_json_string(result, 'expires_at')
|
||||
time_remaining := extract_json_string(result, 'time_remaining')
|
||||
rate_limit := extract_json_string(result, 'rate_limit')
|
||||
burst := extract_json_string(result, 'burst')
|
||||
concurrency := extract_json_string(result, 'concurrency')
|
||||
expired := extract_json_string(result, 'expired')
|
||||
|
||||
if extend && public_key != '' {
|
||||
url := '${portal_base}/keys/extend?pk=${public_key}'
|
||||
println('${yellow}Opening browser: ${url}${reset}')
|
||||
println('${blue}Opening browser to extend key...${reset}')
|
||||
|
||||
// Try xdg-open (Linux), open (macOS), or start (Windows)
|
||||
os.execute('xdg-open "${url}"') or {
|
||||
|
|
@ -149,30 +154,40 @@ fn cmd_key(extend bool, api_key string) {
|
|||
return
|
||||
}
|
||||
|
||||
match status {
|
||||
'valid' {
|
||||
println('${green}Valid${reset}')
|
||||
println('Public Key: ${public_key}')
|
||||
println('Tier: ${tier}')
|
||||
if expired_at != '' {
|
||||
println('Expires: ${expired_at}')
|
||||
}
|
||||
}
|
||||
'expired' {
|
||||
println('${red}Expired${reset}')
|
||||
println('Public Key: ${public_key}')
|
||||
println('Tier: ${tier}')
|
||||
if expired_at != '' {
|
||||
println('Expired: ${expired_at}')
|
||||
}
|
||||
println('${yellow}To renew: Visit ${portal_base}/keys/extend${reset}')
|
||||
}
|
||||
'invalid' {
|
||||
println('${red}Invalid${reset}')
|
||||
}
|
||||
else {
|
||||
println('${yellow}Unknown status: ${status}${reset}')
|
||||
if expired == 'true' {
|
||||
println('${red}Expired${reset}')
|
||||
println('Public Key: ${public_key}')
|
||||
println('Tier: ${tier}')
|
||||
if expires_at != '' {
|
||||
println('Expired: ${expires_at}')
|
||||
}
|
||||
println('${yellow}To renew: Visit https://unsandbox.com/keys/extend${reset}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Valid key
|
||||
println('${green}Valid${reset}')
|
||||
println('Public Key: ${public_key}')
|
||||
if tier != '' {
|
||||
println('Tier: ${tier}')
|
||||
}
|
||||
if status != '' {
|
||||
println('Status: ${status}')
|
||||
}
|
||||
if expires_at != '' {
|
||||
println('Expires: ${expires_at}')
|
||||
}
|
||||
if time_remaining != '' {
|
||||
println('Time Remaining: ${time_remaining}')
|
||||
}
|
||||
if rate_limit != '' {
|
||||
println('Rate Limit: ${rate_limit}')
|
||||
}
|
||||
if burst != '' {
|
||||
println('Burst: ${burst}')
|
||||
}
|
||||
if concurrency != '' {
|
||||
println('Concurrency: ${concurrency}')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue