mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-17 01:10:36 +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,19 +2,19 @@
|
|||||||
|
|
||||||
def "nu-complete rustup" [] {
|
def "nu-complete rustup" [] {
|
||||||
^rustup --help
|
^rustup --help
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Arguments:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete rustup toolchain" [] {
|
def "nu-complete rustup toolchain" [] {
|
||||||
^rustup toolchain
|
^rustup toolchain
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,25 +22,34 @@ def "nu-complete rustup toolchain" [] {
|
|||||||
def "nu-complete rustup toolchain list" [] {
|
def "nu-complete rustup toolchain list" [] {
|
||||||
^rustup toolchain list
|
^rustup toolchain list
|
||||||
| lines
|
| lines
|
||||||
| str replace " (default)" ""
|
|
||||||
| append 'stable'
|
| append 'stable'
|
||||||
| append 'beta'
|
| append 'beta'
|
||||||
| append 'nightly'
|
| 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" [] {
|
def "nu-complete rustup target" [] {
|
||||||
^rustup target
|
^rustup target
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete rustup target list" [] {
|
def "nu-complete rustup target list" [] {
|
||||||
^rustup target list
|
^rustup target list
|
||||||
| lines
|
| 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" [] {
|
def "nu-complete rustup target list --installed" [] {
|
||||||
@ -51,22 +60,30 @@ def "nu-complete rustup target list --installed" [] {
|
|||||||
def "nu-complete rustup update" [] {
|
def "nu-complete rustup update" [] {
|
||||||
^rustup toolchain list
|
^rustup toolchain list
|
||||||
| lines
|
| 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" [] {
|
def "nu-complete rustup component" [] {
|
||||||
^rustup component
|
^rustup component
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete rustup component list" [] {
|
def "nu-complete rustup component list" [] {
|
||||||
^rustup component list
|
^rustup component list
|
||||||
| lines
|
| 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" [] {
|
def "nu-complete rustup component list installed" [] {
|
||||||
@ -77,10 +94,10 @@ def "nu-complete rustup component list installed" [] {
|
|||||||
|
|
||||||
def "nu-complete rustup override" [] {
|
def "nu-complete rustup override" [] {
|
||||||
^rustup override
|
^rustup override
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,19 +117,19 @@ def "nu-complete rustup override list installed" [] {
|
|||||||
|
|
||||||
def "nu-complete rustup self" [] {
|
def "nu-complete rustup self" [] {
|
||||||
^rustup self
|
^rustup self
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete rustup set" [] {
|
def "nu-complete rustup set" [] {
|
||||||
^rustup set
|
^rustup set
|
||||||
| str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' ''
|
| str replace --regex --multiline '(rustup[\s\S]*(?=Commands:))' ''
|
||||||
| str replace --regex --multiline '\n+DISCUSSION[\s\S]*' ''
|
| str replace --regex --multiline '\n+Options:[\s\S]*' ''
|
||||||
| lines
|
| lines
|
||||||
| where $it starts-with " "
|
| where $it starts-with " "
|
||||||
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
| parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +159,10 @@ export extern "rustup" [
|
|||||||
--version(-V) # Print version information
|
--version(-V) # Print version information
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export extern "rustup help" [
|
||||||
|
command?: string@"nu-complete rustup"
|
||||||
|
]
|
||||||
|
|
||||||
export extern "rustup update" [
|
export extern "rustup update" [
|
||||||
command?: string@"nu-complete rustup update"
|
command?: string@"nu-complete rustup update"
|
||||||
--help(-h) # Print help information
|
--help(-h) # Print help information
|
||||||
|
Loading…
Reference in New Issue
Block a user