mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
jc: cache completions
This commit is contained in:
parent
0a36da8326
commit
6ce9922b98
1 changed files with 23 additions and 1 deletions
|
@ -1,5 +1,21 @@
|
||||||
def --env "nu-complete jc" [commandline: string] {
|
def --env "nu-complete jc" [commandline: string] {
|
||||||
try {
|
let stor = stor open
|
||||||
|
|
||||||
|
if $stor.jc_completions? == null {
|
||||||
|
stor create --table-name jc_completions --columns { value: str, description: str }
|
||||||
|
}
|
||||||
|
|
||||||
|
if $stor.jc_completions_ran? == null {
|
||||||
|
stor create --table-name jc_completions_ran --columns { _: bool }
|
||||||
|
}
|
||||||
|
|
||||||
|
if $stor.jc_completions_ran != [] {
|
||||||
|
return $stor.jc_completions
|
||||||
|
} else {
|
||||||
|
stor insert --table-name jc_completions_ran --data-record { _: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
let completions = try {
|
||||||
let about = ^jc --about
|
let about = ^jc --about
|
||||||
| from json
|
| from json
|
||||||
|
|
||||||
|
@ -38,6 +54,12 @@ def --env "nu-complete jc" [commandline: string] {
|
||||||
} catch {
|
} catch {
|
||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for entry in $completions {
|
||||||
|
stor insert --table-name jc_completions --data-record $entry
|
||||||
|
}
|
||||||
|
|
||||||
|
$completions
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run `jc` (JSON Converter).
|
# Run `jc` (JSON Converter).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue