Here is an update for bash-completion to have it use cobbler-completion
John
diff --git a/config/cobbler_bash b/config/cobbler_bash
index 9b55872..20556dd 100644
--- a/config/cobbler_bash
+++ b/config/cobbler_bash
@@ -31,7 +31,7 @@ _cobbler()
prev=${COMP_WORDS[COMP_CWORD-1]}
# Let's only run it once
- SPECIAL_CMDS=`cobbler --helpbash | sed "s/ /|/g"`
+ SPECIAL_CMDS=`cobbler-completion | sed "s/ /|/g"`
for (( i=0; i < [EMAIL PROTECTED]; i++ )); do
if [[ ${COMP_WORDS[i]} == @(${SPECIAL_CMDS}) ]]; then
special=${COMP_WORDS[i]}
@@ -42,7 +42,7 @@ _cobbler()
if [ -n "$special" ]
then
# Take care of sub commands
- SPECIALSUB_CMDS=`cobbler $special --helpsubs | sed "s/ /|/g"`
+ SPECIALSUB_CMDS=`cobbler-completion $special | sed "s/ /|/g"`
if [ -n "${SPECIALSUB_CMDS}" ] ; then
for (( i=0; i < [EMAIL PROTECTED]; i++ )); do
if [[ ${COMP_WORDS[i]} == @(${SPECIALSUB_CMDS}) ]]; then
@@ -52,16 +52,16 @@ _cobbler()
done
else
# This command has no subcommands
- COMPREPLY=( $( compgen -f -W '$( cobbler $special --helpopts )' -- $cur ) )
+ COMPREPLY=( $( compgen -f -W '$( cobbler-completion $special )' -- $cur ) )
return 0
fi
if [ -n "$specialsub" ]
then
- COMPREPLY=( $( compgen -f -W '$( cobbler $special $specialsub --helpopts )' -- $cur ) )
+ COMPREPLY=( $( compgen -f -W '$( cobbler-completion $special $specialsub )' -- $cur ) )
return 0
else
- COMPREPLY=( $( compgen -W '$( cobbler $special --helpsubs )' -- $cur ) )
+ COMPREPLY=( $( compgen -W '$( cobbler-completion $special )' -- $cur ) )
return 0
fi
fi
diff --git a/scripts/cobbler-completion b/scripts/cobbler-completion
index e4d4701..4889662 100755
--- a/scripts/cobbler-completion
+++ b/scripts/cobbler-completion
@@ -15,7 +15,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
import sys
-import os
import cobbler.yaml as yaml
TAKES_A_FILE = [
@@ -32,8 +31,8 @@ def find_completion(args):
data = datafile.read()
datafile.close()
datastruct = yaml.load(data).next()
-
- if args[0] == "cobbler" or args[0] == "/usr/bin/cobbler":
+
+ if args and args[0] in ["cobbler", "/usr/bin/cobbler"]:
args = args[1:]
arguments = args
@@ -112,7 +111,7 @@ def find_options(datastruct, arguments, last):
return datastruct.keys()
def clean_output(datastruct):
- for x in datastruct.keys():
+ for x in sorted(datastruct.keys()):
if x is not None:
sys.stdout.write("%s " % x.replace("'","-"))
print ""
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler