mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-16 17:00:32 +03:00
feat: updated rustup completions to use the new rustup help page style (#871)
Rustup help page changed, so the commands that were based on the old layout to get the completions were broken Improved some completions to include a description like "default" or "installed" Also added completions for `rustup help`
This commit is contained in:
parent
3bceafd6da
commit
de2829091f
@ -2,8 +2,8 @@
|
||||
|
||||
def "nu-complete rustup" [] {
|
||||
^rustup --help
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Arguments:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -11,8 +11,8 @@ def "nu-complete rustup" [] {
|
||||
|
||||
def "nu-complete rustup toolchain" [] {
|
||||
^rustup toolchain
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -22,16 +22,21 @@ def "nu-complete rustup toolchain" [] {
|
||||
def "nu-complete rustup toolchain list" [] {
|
||||
^rustup toolchain list
|
||||
| lines
|
||||
| str replace " (default)" ""
|
||||
| append 'stable'
|
||||
| append 'beta'
|
||||
| append 'nightly'
|
||||
| each { |line| if ($line | str contains "(default)") {
|
||||
{value: ($line | str replace " (default)" ""), description: "default"}
|
||||
} else {
|
||||
{value: $line, description: ""}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def "nu-complete rustup target" [] {
|
||||
^rustup target
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -40,7 +45,11 @@ def "nu-complete rustup target" [] {
|
||||
def "nu-complete rustup target list" [] {
|
||||
^rustup target list
|
||||
| lines
|
||||
| str replace " (installed)" ""
|
||||
| each {|line| if ($line | str contains "installed") {
|
||||
{value: ($line | str replace " (installed)" ""), description: "installed"}
|
||||
} else {
|
||||
{value: $line, description: ""}
|
||||
}}
|
||||
}
|
||||
|
||||
def "nu-complete rustup target list --installed" [] {
|
||||
@ -51,13 +60,17 @@ def "nu-complete rustup target list --installed" [] {
|
||||
def "nu-complete rustup update" [] {
|
||||
^rustup toolchain list
|
||||
| lines
|
||||
| str replace " (default)" ""
|
||||
| each {|line| if ($line | str contains "default") {
|
||||
{value: ($line | str replace " (default)" ""), description: "default"}
|
||||
} else {
|
||||
{value: $line, description: ""}
|
||||
}}
|
||||
}
|
||||
|
||||
def "nu-complete rustup component" [] {
|
||||
^rustup component
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -66,7 +79,11 @@ def "nu-complete rustup component" [] {
|
||||
def "nu-complete rustup component list" [] {
|
||||
^rustup component list
|
||||
| lines
|
||||
| str replace " (installed)" ""
|
||||
| each {|line| if ($line | str contains "installed") {
|
||||
{value: ($line | str replace " (installed)" ""), description: "installed"}
|
||||
} else {
|
||||
{value: $line, description: ""}
|
||||
}}
|
||||
}
|
||||
|
||||
def "nu-complete rustup component list installed" [] {
|
||||
@ -77,8 +94,8 @@ def "nu-complete rustup component list installed" [] {
|
||||
|
||||
def "nu-complete rustup override" [] {
|
||||
^rustup override
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -100,8 +117,8 @@ def "nu-complete rustup override list installed" [] {
|
||||
|
||||
def "nu-complete rustup self" [] {
|
||||
^rustup self
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -109,8 +126,8 @@ def "nu-complete rustup self" [] {
|
||||
|
||||
def "nu-complete rustup set" [] {
|
||||
^rustup set
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
||||
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||
| lines
|
||||
| where $it starts-with " "
|
||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||
@ -142,6 +159,10 @@ export extern "rustup" [
|
||||
--version(-V) # Print version information
|
||||
]
|
||||
|
||||
export extern "rustup help" [
|
||||
command?: string@"nu-complete rustup"
|
||||
]
|
||||
|
||||
export extern "rustup update" [
|
||||
command?: string@"nu-complete rustup update"
|
||||
--help(-h) # Print help information
|
||||
|
Loading…
Reference in New Issue
Block a user