1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-03 07:37:47 +00:00

Check for Labels existence

Run Labels reformatting conditionally as not all docker commands return that field
This commit is contained in:
Yethal 2021-12-13 11:45:55 +01:00 committed by GitHub
parent c8f46f1882
commit ff0017207f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,12 +2,17 @@
def docker [ def docker [
...args:string # command to be passed to the real docker command ...args:string # command to be passed to the real docker command
] { ] {
^docker $args --format={{json .}}| let data = (^docker $args --format={{json .}}|lines|each {$it|from json})
lines| if Labels in ($data|get) {
each { $data|docker labels
$it| } {
from json $data
}| }
}
# subcommand used to reformat docker labels into their own table
def 'docker labels' [] {
update Labels { update Labels {
get Labels| get Labels|
split row ','| split row ','|