mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
mask-completions (#631)
- mask-completions - kubernetes: rename kgpw to kwp --------- Co-authored-by: agent <agent@nuc>
This commit is contained in:
parent
1019cca060
commit
c9d63946ec
2 changed files with 57 additions and 1 deletions
56
custom-completions/mask/mask-completions.nu
Normal file
56
custom-completions/mask/mask-completions.nu
Normal file
|
@ -0,0 +1,56 @@
|
|||
def "nu-complete mask recipes" [] {
|
||||
^mask --introspect
|
||||
| from json
|
||||
| get commands
|
||||
| each {|x|
|
||||
{
|
||||
value: $x.name,
|
||||
description: (
|
||||
$x.description
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def "nu-complete mask args" [context: string, offset: int] {
|
||||
let r = ($context | split row ' ')
|
||||
let c = ^mask --introspect
|
||||
| from json
|
||||
| get commands
|
||||
| where name == $r.1
|
||||
| get 0
|
||||
mut rt = []
|
||||
if not ($c | get required_args | is-empty) {
|
||||
$rt ++= ($c | get required_args | each {|x|
|
||||
{value: null, description: $"($x.name) \(positional)"}
|
||||
})
|
||||
}
|
||||
if not ($c | get subcommands | is-empty) {
|
||||
$rt ++= ($c | get subcommands | each {|x|
|
||||
{value: $x.name, description: $"($x.description) \(subcommand)"}
|
||||
})
|
||||
}
|
||||
if not ($c | get named_flags | is-empty) {
|
||||
$rt ++= ($c | get named_flags | each {|x|
|
||||
let v = if not ($x.long | is-empty) { $"`--($x.long)`" } else if not ($x.short | is-empty) { $"`-($x.short)`" } else { $"---($x.name)" }
|
||||
let a = ["required", "multiple", "takes_value", "validate_as_number"]
|
||||
| filter {|y| ($x | get $y) == true }
|
||||
| str join ','
|
||||
let d = if ($a | is-empty) { $x.description } else { $"($x.description) \(($a))" }
|
||||
{value: $v , description: $d }
|
||||
})
|
||||
}
|
||||
|
||||
$rt
|
||||
}
|
||||
|
||||
export def main [
|
||||
recipes?: string@"nu-complete mask recipes"
|
||||
...args: any@"nu-complete mask args"
|
||||
] {
|
||||
if ($recipes | is-empty) {
|
||||
^mask --help
|
||||
} else {
|
||||
^mask $recipes $args
|
||||
}
|
||||
}
|
|
@ -629,7 +629,7 @@ export def kgp [
|
|||
}
|
||||
|
||||
# kubectl get pods --watch
|
||||
export def kgpw [
|
||||
export def kwp [
|
||||
r?: string@"nu-complete kube res via name"
|
||||
--namespace (-n): string@"nu-complete kube ns"
|
||||
--selector (-l): string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue