mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
rename registry list to registry show (#480)
* rename registry list to registry show Extend its functionality, not just list tags, but also show catalog and manifest, Depending on the number of parameters. * date format by $theme.format show day of the week shortly time_segment --------- Co-authored-by: agent <agent@nuc>
This commit is contained in:
parent
25c85042f1
commit
3645bae992
2 changed files with 31 additions and 21 deletions
|
@ -316,39 +316,48 @@ export def dr [
|
|||
}
|
||||
}
|
||||
|
||||
def "nu-complete registry list" [cmd: string, offset: int] {
|
||||
def has [name] {
|
||||
$name in ($in | columns) and (not ($in | get $name | is-empty))
|
||||
}
|
||||
|
||||
def "nu-complete registry show" [cmd: string, offset: int] {
|
||||
let new = ($cmd | str ends-with ' ')
|
||||
let cmd = ($cmd | split row ' ')
|
||||
let url = (do -i { $cmd | get 2 })
|
||||
let reg = (do -i { $cmd | get 3 })
|
||||
let tag = (do -i { $cmd | get 4 })
|
||||
if ($reg|is-empty) {
|
||||
if ($env | has 'REGISTRY_TOKEN') {
|
||||
http get -H [authorization $"Basic ($env.REGISTRY_TOKEN)"] $"($url)/v2/_catalog"
|
||||
} else {
|
||||
http get $"($url)/v2/_catalog"
|
||||
}
|
||||
let auth = if ($env | has 'REGISTRY_TOKEN') {
|
||||
[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
|
||||
} else if ($tag|is-empty) {
|
||||
if ($env | has 'REGISTRY_TOKEN') {
|
||||
http get $"($url)/v2/($reg)/tags/list"
|
||||
} else {
|
||||
http get -H [authorization $"Basic ($env.REGISTRY_TOKEN)"] $"($url)/v2/($reg)/tags/list"
|
||||
}
|
||||
} else {
|
||||
http get -H $auth $"($url)/v2/($reg)/tags/list"
|
||||
| get tags
|
||||
}
|
||||
}
|
||||
|
||||
### docker registry list
|
||||
export def "registry list" [
|
||||
### docker registry show
|
||||
export def "registry show" [
|
||||
url: string
|
||||
reg: string@"nu-complete registry list"
|
||||
reg?: string@"nu-complete registry show"
|
||||
tag?: string@"nu-complete registry show"
|
||||
] {
|
||||
if ($env.REGISTRY_TOKEN? | is-empty) {
|
||||
http get $"($url)/v2/($reg)/tags/list"
|
||||
let auth = if ($env | has 'REGISTRY_TOKEN') {
|
||||
[authorization $"Basic ($env.REGISTRY_TOKEN)"]
|
||||
} else {
|
||||
http get -H [authorization $"Basic ($env.REGISTRY_TOKEN)"] $"($url)/v2/($reg)/tags/list"
|
||||
[]
|
||||
}
|
||||
if ($reg | is-empty) {
|
||||
http get -H $auth $"($url)/v2/_catalog" | get repositories
|
||||
} else if ($tag | is-empty) {
|
||||
http get -H $auth $"($url)/v2/($reg)/tags/list" | get tags
|
||||
} else {
|
||||
http get -e -H [accept 'application/vnd.oci.image.manifest.v1+json'] -H $auth $"($url)/v2/($reg)/manifests/($tag)" | from json
|
||||
}
|
||||
| get tags
|
||||
}
|
||||
|
||||
### buildah
|
||||
|
|
|
@ -78,7 +78,7 @@ def host_abbr [] {
|
|||
def time_segment [] {
|
||||
{||
|
||||
let theme = $env.NU_POWER_THEME.time
|
||||
$"($theme.now)(date now | date format '%y-%m-%d_%H:%M:%S')"
|
||||
$"($theme.now)(date now | date format $theme.format)"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,6 +551,7 @@ export-env {
|
|||
}
|
||||
time: {
|
||||
now: (ansi xterm_tan)
|
||||
format: '%y%m%d[%w]%H%M%S'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue