1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-07-30 21:57:44 +00:00

in commands table rename usage to description (#990)

`usage` column under the `scope commands` table has been renamed to
description since nushell version 0.98.0
This commit is contained in:
ff2400t 2024-12-08 18:57:33 +05:30 committed by GitHub
parent 09c4ca4ac0
commit b5385a2af0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View file

@ -25,6 +25,6 @@
source: { |buffer, position| source: { |buffer, position|
scope commands scope commands
| where name =~ $buffer | where name =~ $buffer
| each { |it| {value: $it.name description: $it.usage} } | each { |it| {value: $it.name description: $it.description } }
} }
} }

View file

@ -27,6 +27,6 @@
source: { |buffer, position| source: { |buffer, position|
scope commands scope commands
| where name =~ $buffer | where name =~ $buffer
| each { |it| {value: $it.name description: $it.usage} } | each { |it| {value: $it.name description: $it.description} }
} }
} }

View file

@ -16,7 +16,7 @@ export function activate(context: vscode.ExtensionContext) {
# generate typescript from nushell commands # generate typescript from nushell commands
def gen-ts-cmds [] { def gen-ts-cmds [] {
let cmds = (scope commands | where usage != '' | select name usage) let cmds = (scope commands | where description != '' | select name description)
let updated_cmds = (echo $cmds | insert camel {|it| $it.name + 'Completion' | str camel-case } ) let updated_cmds = (echo $cmds | insert camel {|it| $it.name + 'Completion' | str camel-case } )
let ts = (echo $updated_cmds | let ts = (echo $updated_cmds |
@ -38,10 +38,10 @@ def gen-ts-cmds [] {
# generate typescript from nushell subcommands # generate typescript from nushell subcommands
def gen-ts-subs [] { def gen-ts-subs [] {
let cmds = (scope commands | where is_sub == true | select name usage | insert base { get name | split column ' ' base sub } | flatten --all) let cmds = (scope commands | where is_sub == true | select name description | insert base { get name | split column ' ' base sub } | flatten --all)
let updated_cmds = (echo $cmds | insert camelProvider {|row| $row.base + 'SubCommandsProvider' | str camel-case } | insert method {|row| $row.name | str camel-case}) let updated_cmds = (echo $cmds | insert camelProvider {|row| $row.base + 'SubCommandsProvider' | str camel-case } | insert method {|row| $row.name | str camel-case})
let subs_count = (scope commands | where is_sub == true | select name usage | insert base { get name | split column ' ' base sub} | flatten --all | group-by base | transpose cmd cmd_count | update cmd_count { get cmd_count | length }) let subs_count = (scope commands | where is_sub == true | select name description | insert base { get name | split column ' ' base sub} | flatten --all | group-by base | transpose cmd cmd_count | update cmd_count { get cmd_count | length })
let subs_collection = (scope commands | where is_sub == true | select name usage | insert base { get name | split column ' ' base sub} | flatten --all | group-by base | transpose cmd sub_cmds) let subs_collection = (scope commands | where is_sub == true | select name description | insert base { get name | split column ' ' base sub} | flatten --all | group-by base | transpose cmd sub_cmds)
let ts = ($subs_collection | each {|it| let ts = ($subs_collection | each {|it|
let preamble = (get sub_cmds | enumerate | each {|it| let preamble = (get sub_cmds | enumerate | each {|it|
@ -55,11 +55,11 @@ def gen-ts-subs [] {
let line05 = ([ " const linePrefix = document.lineAt(position).text.substr(0, position.character);" (char nl) ] | str join) let line05 = ([ " const linePrefix = document.lineAt(position).text.substr(0, position.character);" (char nl) ] | str join)
let line06 = ([ " if (linePrefix.endsWith('" $it.item.base " ')) {" (char nl) (char nl) ] | str join) let line06 = ([ " if (linePrefix.endsWith('" $it.item.base " ')) {" (char nl) (char nl) ] | str join)
let line07 = ([ " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl) ] | str join) let line07 = ([ " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl) ] | str join)
let line08 = ([ ' ' $method '.detail = "' $it.item.usage '";' (char nl) (char nl) ] | str join) let line08 = ([ ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl) ] | str join)
$line01 + $line02 + $line03 + $line04 + $line05 + $line06 + $line07 + $line08 $line01 + $line02 + $line03 + $line04 + $line05 + $line06 + $line07 + $line08
} else { } else {
let line07 = ([ " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl) ] | str join) let line07 = ([ " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl) ] | str join)
let line08 = ([ ' ' $method '.detail = "' $it.item.usage '";' (char nl) (char nl) ] | str join) let line08 = ([ ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl) ] | str join)
$line07 + $line08 $line07 + $line08
} }
} | str join) } | str join)

View file

@ -17,7 +17,7 @@ export def fuzzy-command-search [] {
let max_indent = ($max_len / $tablen | into int) let max_indent = ($max_len / $tablen | into int)
let command = ((help commands | each {|it| let command = ((help commands | each {|it|
let name = ($it.name | str trim | ansi strip) let name = ($it.name | str trim | ansi strip)
$"($name)(pad-tabs $name $max_indent)($it.usage)" $"($name)(pad-tabs $name $max_indent)($it.description)"
}) | str join (char nl) | fzf | split column (char tab) | get column1.0) }) | str join (char nl) | fzf | split column (char tab) | get column1.0)
if ($command | is-not-empty) { if ($command | is-not-empty) {
help $command help $command