mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 14:47:47 +00:00
[completions-cargo] complete targets from cargo metadata (#194)
* complete targets from cargo metadata for more precise completions we probably should use cargo metadata to get the available targets * fix typo
This commit is contained in:
parent
7320f99f59
commit
f394c2819e
1 changed files with 4 additions and 12 deletions
|
@ -1,18 +1,10 @@
|
|||
## Written by lukexor
|
||||
|
||||
def "nu-complete cargo bins" [] {
|
||||
let $bins = (ls src | where name =~ bin | each { |f| ls -s $f.name } | flatten | where name =~ .rs || type == dir)
|
||||
if ($bins | length) > 0 {
|
||||
echo $bins | upsert name { |file| $file.name | str find-replace ".rs" "" } | get name
|
||||
}
|
||||
}
|
||||
|
||||
def "nu-complete cargo examples" [] {
|
||||
let $examples = (ls | where name =~ examples | each { |f| ls -s $f.name } | flatten | where name =~ .rs || type == dir)
|
||||
if ($examples | length) > 0 {
|
||||
echo $examples | upsert name { |file| $file.name | str find-replace ".rs" "" } | get name
|
||||
}
|
||||
def "nu-complete cargo targets" [type: string] {
|
||||
cargo metadata --format-version=1 --offline --no-deps | from json | get packages.targets | flatten | where ($type in $it.kind) | get name
|
||||
}
|
||||
def "nu-complete cargo bins" [] { nu-complete cargo targets bin }
|
||||
def "nu-complete cargo examples" [] { nu-complete cargo targets example }
|
||||
|
||||
def "nu-complete cargo packages" [] {
|
||||
let metadata = (cargo metadata --format-version=1 --offline --no-deps)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue