From c1439c1cbd95853309fe2491358b013b68239ae0 Mon Sep 17 00:00:00 2001 From: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Date: Tue, 19 Apr 2011 14:03:23 +0300 Subject: [PATCH] Make bash completion network-aware Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr> --- autotools/build-bash-completion | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion index bb53f607a..e2cabb5c5 100755 --- a/autotools/build-bash-completion +++ b/autotools/build-bash-completion @@ -126,6 +126,15 @@ def WritePreamble(sw): sw.DecIndent() sw.Write("}") + sw.Write("_ganeti_network() {") + sw.IncIndent() + try: + networks_path = os.path.join(constants.DATA_DIR, "ssconf_networks") + sw.Write("cat %s 2>/dev/null || :", utils.ShellQuote(networks_path)) + finally: + sw.DecIndent() + sw.Write("}") + # Params: <offset> <options with values> <options without values> # Result variable: $first_arg_idx sw.Write("_ganeti_find_first_arg() {") @@ -339,6 +348,8 @@ class CompletionWriter: WriteCompReply(sw, "-W \"$(_ganeti_iallocator)\"", cur=cur) elif suggest == cli.OPT_COMPL_ONE_NODEGROUP: WriteCompReply(sw, "-W \"$(_ganeti_nodegroup)\"", cur=cur) + elif suggest == cli.OPT_COMPL_ONE_NETWORK: + WriteCompReply(sw, "-W \"$(_ganeti_network)\"", cur=cur) elif suggest == cli.OPT_COMPL_INST_ADD_NODES: sw.Write("local tmp= node1= pfx= curvalue=\"${optcur#*:}\"") @@ -440,6 +451,8 @@ class CompletionWriter: choices = "$(_ganeti_nodes)" elif isinstance(arg, cli.ArgGroup): choices = "$(_ganeti_nodegroup)" + elif isinstance(arg, cli.ArgNetwork): + choices = "$(_ganeti_network)" elif isinstance(arg, cli.ArgJobId): choices = "$(_ganeti_jobs)" elif isinstance(arg, cli.ArgOs): -- GitLab