1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

a little cleanup (#444)

This commit is contained in:
Darren Schroeder 2023-04-12 08:27:23 -05:00 committed by GitHub
parent 40459e646d
commit 40ad482307
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 58 deletions

View file

@ -1,19 +0,0 @@
#Fetch simple anwser from WolframAlpha API
def wolfram [...query #Your query
] {
let appID = #YOUR APP_ID
let query_string = ($query | str collect " ")
let result = (fetch ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | to url)))
$result + ""
}
#Fetch image with full anwser from WolframAlpha API
def wolframimg [...query #Your query
] {
let appID = #YOUR APP_ID
let query_string = ($query | str collect " ")
let filename = ($query_string + ".png")
let link = ("https://api.wolframalpha.com/v1/simple?" + ([[appid i]; [$appID $query_string]] | to url) + "&background=F5F5F5&fontsize=20")
fetch $link | save $filename
echo ("Query result saved in file: " + $filename)
}

View file

@ -1,20 +0,0 @@
let filter = ($nu.lang | where is_filter == $true | length)
let builtin = ($nu.lang | where is_builtin == $true | length)
let subcmd = ($nu.lang | where is_sub == $true | length)
let plugin = ($nu.lang | where is_plugin == $true | length)
let custom = ($nu.lang | where is_custom == $true | length)
let private = ($nu.lang | where is_private == $true | length)
let binary = ($nu.lang | where is_binary == $true | length)
let total = ($nu.lang | length)
[
[command_type count];
[filter $filter]
[builtin $builtin]
[sub_command $subcmd]
[plugin $plugin]
[custom $custom]
[private $private]
[binary $binary]
[total_cmds $total]
]

18
misc/cmd_stats.nu Normal file
View file

@ -0,0 +1,18 @@
let builtin = ($nu.scope.commands | where is_builtin == true | length)
let subcmd = ($nu.scope.commands | where is_sub == true | length)
let plugin = ($nu.scope.commands | where is_plugin == true | length)
let custom = ($nu.scope.commands | where is_custom == true | length)
let keyword = ($nu.scope.commands | where is_keyword == true | length)
let extern = ($nu.scope.commands | where is_extern == true | length)
let total = ($nu.scope.commands | length)
[
[command_type count];
[builtin $builtin]
[sub_command $subcmd]
[plugin $plugin]
[custom $custom]
[keyword $keyword]
[extern $extern]
[total_cmds $total]
]

View file

@ -1,37 +1,37 @@
let table = (echo [
[url user_login title];
[url user_login title];
[https://api.github.com/repos/nushell/nushell/issues/3382 ammkrn 'Dont unwrap rustyline helper in cli']
[https://api.github.com/repos/nushell/nushell/issues/3379 jonathandturner 'Simplify down to one type of context']
[https://api.github.com/repos/nushell/nushell/issues/3379 jonathandturner 'Simplify down to one type of context']
[https://api.github.com/repos/nushell/nushell/issues/3377 kubouch 'Port range to engine-p']
[https://api.github.com/repos/nushell/nushell/issues/3375 fdncred 'added check for endian-ness, added a bytes and skip']
[https://api.github.com/repos/nushell/nushell/issues/3374 fdncred 'added ability to change "]
[https://api.github.com/repos/nushell/nushell/issues/3370 fdncred 'add nu-pretty-hex, add into binary, update binaryview']
[https://api.github.com/repos/nushell/nushell/issues/3375 fdncred 'added check for endian-ness, added a bytes and skip']
[https://api.github.com/repos/nushell/nushell/issues/3374 fdncred 'added ability to change ']
[https://api.github.com/repos/nushell/nushell/issues/3370 fdncred 'add nu-pretty-hex, add into binary, update binaryview']
[https://api.github.com/repos/nushell/nushell/issues/3367 fdncred 'tweaked the error handling to show specific errors']
])
# Show what the table looks like
$"This is an example table (char nl)"
$table
print $"This is an example table (char nl)"
print $table
$"This is markdown created from the example table (char nl)"
print $"This is markdown created from the example table (char nl)"
# Now show what the table in Markdown looks like
$"## Nushell(char nl)(char nl)"
$table | group-by user_login | pivot user prs | each { |row|
print $"## Nushell(char nl)(char nl)"
print ($table | group-by user_login | transpose user prs | each { |row|
let user_name = $row.user
let pr_count = (echo $row.prs | length)
# only print the comma if there's another item
let user_prs = ($row.prs | each -n { |pr|
let user_prs = ($row.prs | enumerate | each { |pr|
if $pr_count == ($pr.index + 1) {
build-string '[' $pr.item.title '](' $pr.item.url ')'
} {
build-string '[' $pr.item.title '](' $pr.item.url '), and '
echo $'[($pr.item.title)](char lp)($pr.item.url)(char rp)'
} else {
echo $'[($pr.item.title)](char lp)($pr.item.url)(char rp), and '
}
} | str collect)
} | str join)
$"- ($user_name) created ($user_prs) (char nl)"
echo $"- ($user_name) created ($user_prs) (char nl)"
} | str collect
} | str join)
# ╭───┬──────────────────────────────────────────────────────────┬─────────────────┬───────────────────────────────────────────────────────╮
# │ # │ url │ user_login │ title │
@ -47,6 +47,6 @@ $table | group-by user_login | pivot user prs | each { |row|
def log [message:any] {
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
let mess = (build-string $now '|DBG|' $message (char newline))
echo $mess | autoview
let mess = ([$now '|DBG|' $message (char newline)] | str join)
echo $mess
}