-
Notifications
You must be signed in to change notification settings - Fork 1
/
kafka-topics.sh.autocomplete
56 lines (42 loc) · 2.39 KB
/
kafka-topics.sh.autocomplete
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# vi: ft=bash
. ./helpers.sh
#INCLUDE
_kafka_topics_complete() {
local all_types='--alter|--at-min-isr-partitions|--bootstrap-server|--command-config|--config|--create|--delete|--delete-config|--describe|--disable-rack-aware|--exclude-internal|--force|--help|--if-exists|--if-not-exists|--list|--partitions|--replica-assignment|--replication-factor|--topic|--topics-with-overrides|--unavailable-partitions|--under-min-isr-partitions|--under-replicated-partitions|--version|--zookeeper'
local types_with_args='--bootstrap-server|--command-config|--config|--delete-config|--partitions|--replica-assignment|--replication-factor|--topic|--zookeeper'
local configs='cleanup.policy=|compression.type=|delete.retention.ms=|file.delete.delay.ms=|flush.messages=|flush.ms=|follower.replication.throttled.replicas=|index.interval.bytes=|leader.replication.throttled.replicas=|max.compaction.lag.ms=|max.message.bytes=|message.downconversion.enable=|message.format.version=|message.timestamp.difference.max.ms=|message.timestamp.type=|min.cleanable.dirty.ratio=|min.compaction.lag.ms=|min.insync.replicas=|preallocate=|retention.bytes=|retention.ms=|segment.bytes=|segment.index.bytes=|segment.jitter.ms=|segment.ms=|unclean.leader.election.enable='
local cur prev words cword candidates
_init_completion -n : # and don't split on a colon
case "$prev" in
'--bootstrap-server')
candidates="${KAFKA_BOOTSTRAP_SERVER:-localhost:9092}"
;;
'--topic')
candidates="$(_get_topics)"
;;
'--config')
compopt -o nospace # don't stick a space after the config=
candidates="$configs"
;;
'--command-config')
compopt -o default # auto-complete with files
;;
'--delete-config')
candidates="${configs//=}" # remove the equalses from the candidates
;;
#https://stackoverflow.com/a/13254908/591948
@($types_with_args))
# no suggestions - type needs an arg of some kind
;;
*)
# it's a regular cmd option starting with -
if [[ ${cur} == -* ]] ; then
candidates="$all_types"
fi
;;
esac
[[ ! -z "$candidates" ]] && COMPREPLY=($(IFS=$' \t\n|' compgen -W "$candidates" -- ${cur}) )
return 0
}
# END_INCLUDE
complete -F _kafka_topics_complete kafka-topics.sh