Implements the following new CLI features:
- service logs is no longer experimental
- service logs also accepts task IDs
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit 47615c9b9bfc947a2b244317188db54aa29c716e)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
| ... | ... |
@@ -463,6 +463,16 @@ __docker_complete_services() {
|
| 463 | 463 |
COMPREPLY=( $(compgen -W "$(__docker_services "$@")" -- "$current") ) |
| 464 | 464 |
} |
| 465 | 465 |
|
| 466 |
+# __docker_tasks returns a list of all task IDs. |
|
| 467 |
+__docker_tasks() {
|
|
| 468 |
+ __docker_q service ps --format '{{.ID}}' ""
|
|
| 469 |
+} |
|
| 470 |
+ |
|
| 471 |
+# __docker_complete_services_and_tasks applies completion of services and task IDs. |
|
| 472 |
+__docker_complete_services_and_tasks() {
|
|
| 473 |
+ COMPREPLY=( $(compgen -W "$(__docker_services "$@") $(__docker_tasks)" -- "$cur") ) |
|
| 474 |
+} |
|
| 475 |
+ |
|
| 466 | 476 |
# __docker_append_to_completions appends the word passed as an argument to every |
| 467 | 477 |
# word in `$COMPREPLY`. |
| 468 | 478 |
# Normally you do this with `compgen -S` while generating the completions. |
| ... | ... |
@@ -2830,13 +2840,13 @@ _docker_service() {
|
| 2830 | 2830 |
local subcommands=" |
| 2831 | 2831 |
create |
| 2832 | 2832 |
inspect |
| 2833 |
+ logs |
|
| 2833 | 2834 |
ls |
| 2834 | 2835 |
rm |
| 2835 | 2836 |
scale |
| 2836 | 2837 |
ps |
| 2837 | 2838 |
update |
| 2838 | 2839 |
" |
| 2839 |
- __docker_daemon_is_experimental && subcommands+="logs" |
|
| 2840 | 2840 |
|
| 2841 | 2841 |
local aliases=" |
| 2842 | 2842 |
list |
| ... | ... |
@@ -2888,7 +2898,7 @@ _docker_service_logs() {
|
| 2888 | 2888 |
*) |
| 2889 | 2889 |
local counter=$(__docker_pos_first_nonflag '--since|--tail') |
| 2890 | 2890 |
if [ $cword -eq $counter ]; then |
| 2891 |
- __docker_complete_services |
|
| 2891 |
+ __docker_complete_services_and_tasks |
|
| 2892 | 2892 |
fi |
| 2893 | 2893 |
;; |
| 2894 | 2894 |
esac |