Skip to content
Snippets Groups Projects
Commit a10caf87 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

bash_completion: Move common code into function


This reduces the size of the script by about 9 kB.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 25c92bc5
No related branches found
No related tags found
No related merge requests found
......@@ -236,10 +236,20 @@ def WritePreamble(sw):
sw.DecIndent()
sw.Write("}")
# Params: <compgen options>
# Result variable: $COMPREPLY
sw.Write("_ganeti_compgen() {")
sw.IncIndent()
try:
sw.Write("""COMPREPLY=( $(compgen "$@") )""")
sw.Write("_ganeti_dbglog COMPREPLY=\"${COMPREPLY[@]}\"")
finally:
sw.DecIndent()
sw.Write("}")
def WriteCompReply(sw, args, cur="\"$cur\""):
sw.Write("""COMPREPLY=( $(compgen %s -- %s) )""", args, cur)
sw.Write("_ganeti_dbglog COMPREPLY=\"${COMPREPLY[@]}\"")
sw.Write("_ganeti_compgen %s -- %s", args, cur)
sw.Write("return")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment