mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
new module comma and some updates (#704)
update: - cwdhist: openeditor changed from alt+e to alt+o - docker: pull, push add nerdctl insecure-registry support - docker: registry show use curl instead http get (may cause dns resolution problems) - git: status `table -n` changed to `table -i` new module: comma Similar to `pwd-module`, but supports completion and description through custom data formats - `,` or `*` need to be exported in order to use `,` directly - Directly execute `,` to create a new template file or edit an existing file - Custom tasks are written in `$env.comma` and can be nested - Generate completions based on the structure of `$env.comma` - You can use closure to customize completion - In `$env.commax.act` of default closure, you can receive parameters after the current position - In `$env.commax.cmp` , you can receive the parameter before the current position --------- Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
parent
6f1c0dfef2
commit
fce44fbbfd
6 changed files with 318 additions and 28 deletions
|
@ -7,10 +7,8 @@ export-env {
|
|||
}
|
||||
}
|
||||
|
||||
def --wrapped with-flag [...ns] {
|
||||
if ($in | is-empty) { [] } else {
|
||||
[$ns $in] | flatten
|
||||
}
|
||||
def --wrapped with-flag [...flag] {
|
||||
if ($in | is-empty) { [] } else { [...$flag $in] }
|
||||
}
|
||||
|
||||
def local_image [name] {
|
||||
|
@ -209,13 +207,15 @@ export def image-tag [from: string@"nu-complete docker images" to: string -n: s
|
|||
}
|
||||
|
||||
# push image
|
||||
export def image-push [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] {
|
||||
^$env.docker-cli ($n | with-flag -n) push $img
|
||||
export def image-push [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns" -i] {
|
||||
let $insecure = if $i {[--insecure-registry]} else {[]}
|
||||
^$env.docker-cli ($n | with-flag -n) $insecure push $img
|
||||
}
|
||||
|
||||
# pull image
|
||||
export def image-pull [img -n: string@"nu-complete docker ns"] {
|
||||
^$env.docker-cli ($n | with-flag -n) pull $img
|
||||
export def image-pull [img -n: string@"nu-complete docker ns" -i] {
|
||||
let $insecure = if $i {[--insecure-registry]} else {[]}
|
||||
^$env.docker-cli ($n | with-flag -n) $insecure pull $img
|
||||
}
|
||||
|
||||
### list volume
|
||||
|
@ -349,16 +349,16 @@ def "nu-complete registry show" [cmd: string, offset: int] {
|
|||
let reg = $cmd.3?
|
||||
let tag = $cmd.4?
|
||||
let auth = if ($env | has 'REGISTRY_TOKEN') {
|
||||
[authorization $"Basic ($env.REGISTRY_TOKEN)"]
|
||||
[-H $"Authorization: Basic ($env.REGISTRY_TOKEN)"]
|
||||
} else {
|
||||
[]
|
||||
}
|
||||
if ($tag | is-empty) and (not $new) or ($reg | is-empty) {
|
||||
http get -H $auth $"($url)/v2/_catalog"
|
||||
| get repositories
|
||||
curl -sSL $auth $"($url)/v2/_catalog"
|
||||
| from json | get repositories
|
||||
} else {
|
||||
http get -H $auth $"($url)/v2/($reg)/tags/list"
|
||||
| get tags
|
||||
curl -sSL $auth $"($url)/v2/($reg)/tags/list"
|
||||
| from json | get tags
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,16 +369,16 @@ export def "registry show" [
|
|||
tag?: string@"nu-complete registry show"
|
||||
] {
|
||||
let auth = if ($env | has 'REGISTRY_TOKEN') {
|
||||
[authorization $"Basic ($env.REGISTRY_TOKEN)"]
|
||||
[-H $"Authorization: Basic ($env.REGISTRY_TOKEN)"]
|
||||
} else {
|
||||
[]
|
||||
}
|
||||
if ($reg | is-empty) {
|
||||
http get -H $auth $"($url)/v2/_catalog" | get repositories
|
||||
curl -sSL $auth $"($url)/v2/_catalog" | from json | get repositories
|
||||
} else if ($tag | is-empty) {
|
||||
http get -H $auth $"($url)/v2/($reg)/tags/list" | get tags
|
||||
curl -sSL $auth $"($url)/v2/($reg)/tags/list" | from json | get tags
|
||||
} else {
|
||||
http get -e -H [accept 'application/vnd.oci.image.manifest.v1+json'] -H $auth $"($url)/v2/($reg)/manifests/($tag)" | from json
|
||||
curl -sSL -H 'Accept: application/vnd.oci.image.manifest.v1+json' $auth $"($url)/v2/($reg)/manifests/($tag)" | from json
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue