Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shorthand for --tail option #2646

Merged
merged 2 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/command/container/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewLogsCommand(dockerCli command.Cli) *cobra.Command {
flags.SetAnnotation("until", "version", []string{"1.35"})
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps")
flags.BoolVar(&opts.details, "details", false, "Show extra details provided to logs")
flags.StringVar(&opts.tail, "tail", "all", "Number of lines to show from the end of the logs")
flags.StringVarP(&opts.tail, "tail", "n", "all", "Number of lines to show from the end of the logs")
return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion cli/command/service/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newLogsCommand(dockerCli command.Cli) *cobra.Command {
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps")
flags.BoolVar(&opts.details, "details", false, "Show extra details provided to logs")
flags.SetAnnotation("details", "version", []string{"1.30"})
flags.StringVar(&opts.tail, "tail", "all", "Number of lines to show from the end of the logs")
flags.StringVarP(&opts.tail, "tail", "n", "all", "Number of lines to show from the end of the logs")
return cmd
}

Expand Down
12 changes: 6 additions & 6 deletions contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -1672,17 +1672,17 @@ _docker_container_kill() {

_docker_container_logs() {
case "$prev" in
--since|--tail|--until)
--since|--tail|-n|--until)
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--details --follow -f --help --since --tail --timestamps -t --until" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--details --follow -f --help --since --tail -n --timestamps -t --until" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--since|--tail|--until')
local counter=$(__docker_pos_first_nonflag '--since|--tail|-n|--until')
if [ "$cword" -eq "$counter" ]; then
__docker_complete_containers_all
fi
Expand Down Expand Up @@ -3526,17 +3526,17 @@ _docker_service_inspect() {

_docker_service_logs() {
case "$prev" in
--since|--tail)
--since|--tail|-n)
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--details --follow -f --help --no-resolve --no-task-ids --no-trunc --raw --since --tail --timestamps -t" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--details --follow -f --help --no-resolve --no-task-ids --no-trunc --raw --since --tail -n --timestamps -t" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--since|--tail')
local counter=$(__docker_pos_first_nonflag '--since|--tail|-n')
if [ "$cword" -eq "$counter" ]; then
__docker_complete_services_and_tasks
fi
Expand Down
2 changes: 1 addition & 1 deletion contrib/completion/fish/docker.fish
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -s f -l follow -d
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l help -d 'Print usage'
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -s t -l timestamps -d 'Show timestamps'
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l since -d 'Show logs since timestamp'
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l tail -d 'Output the specified number of lines at the end of logs (defaults to all logs)'
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -s n -l tail -d 'Output the specified number of lines at the end of logs (defaults to all logs)'
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -a '(__fish_print_docker_containers running)' -d "Container"

# network
Expand Down
4 changes: 2 additions & 2 deletions contrib/completion/zsh/_docker
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ __docker_container_subcommand() {
"($help -f --follow)"{-f,--follow}"[Follow log output]" \
"($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \
"($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
"($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \
"($help -n --tail)"{-n=,--tail=}"[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
"($help -)*:containers:__docker_complete_containers" && ret=0
;;
(ls|list)
Expand Down Expand Up @@ -2038,7 +2038,7 @@ __docker_service_subcommand() {
"($help)--no-task-ids[Do not include task IDs]" \
"($help)--no-trunc[Do not truncate output]" \
"($help)--since=[Show logs since timestamp]:timestamp: " \
"($help)--tail=[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
"($help -n --tail)"{-n=,--tail=}"[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
"($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
"($help -)1:service:__docker_complete_services" && ret=0
;;
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commandline/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Options:
--help Print usage
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
--until string Show logs before timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
--tail string Number of lines to show from the end of the logs (default "all")
-n, --tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
```

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commandline/service_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Options:
--no-task-ids Do not include task IDs in output
--no-trunc Do not truncate output
--since string Show logs since timestamp
--tail string Number of lines to show from the end of the logs (default "all")
-n, --tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
```

Expand Down