mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-17 01:10:36 +03:00
new cmd: container-log-trunc (#761)
clean container-log-namespace Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
parent
e8f4d7462a
commit
144f3fefde
@ -145,16 +145,10 @@ def "nu-complete docker images" [] {
|
||||
| each {|x| $"($x.REPOSITORY):($x.TAG)"}
|
||||
}
|
||||
|
||||
# container log
|
||||
export def container-log [ctn: string@"nu-complete docker containers"
|
||||
-l: int = 100 # line
|
||||
] {
|
||||
let l = if $l == 0 { [] } else { [--tail $l] }
|
||||
^$env.docker-cli logs -f ...$l $ctn
|
||||
}
|
||||
|
||||
# container log with namespace
|
||||
export def container-log-namespace [ctn: string@"nu-complete docker containers"
|
||||
# container log
|
||||
export def container-log [
|
||||
ctn: string@"nu-complete docker containers"
|
||||
-l: int = 100 # line
|
||||
-n: string@"nu-complete docker ns" # namespace
|
||||
] {
|
||||
@ -162,6 +156,18 @@ export def container-log-namespace [ctn: string@"nu-complete docker containers"
|
||||
^$env.docker-cli ...($n | with-flag -n) logs -f ...$l $ctn
|
||||
}
|
||||
|
||||
export def container-log-trunc [
|
||||
ctn: string@"nu-complete docker containers"
|
||||
-n: string@"nu-complete docker ns" # namespace
|
||||
] {
|
||||
if $env.docker-cli == 'podman' {
|
||||
print -e $'(ansi yellow)podman(ansi dark_gray) isn’t supported(ansi reset)'
|
||||
} else {
|
||||
let f = ^$env.docker-cli ...($n | with-flag -n) inspect --format='{{.LogPath}}' $ctn
|
||||
truncate -s 0 $f
|
||||
}
|
||||
}
|
||||
|
||||
# attach container
|
||||
export def --wrapped container-attach [
|
||||
ctn: string@"nu-complete docker containers"
|
||||
@ -498,7 +504,7 @@ export def "bud rm" [
|
||||
export alias dp = container-list
|
||||
export alias di = image-list
|
||||
export alias dl = container-log
|
||||
export alias dln = container-log-namespace
|
||||
export alias dlt = container-log-trunc
|
||||
export alias da = container-attach
|
||||
export alias dcp = container-copy-file
|
||||
export alias dcr = container-remove
|
||||
|
Loading…
Reference in New Issue
Block a user