Here is the latest bash-completion script against the development
branch as of this morning.
diff --git a/cobbler/commands.py b/cobbler/commands.py
index 4a620a3..f65438b 100644
--- a/cobbler/commands.py
+++ b/cobbler/commands.py
@@ -172,20 +172,17 @@ class CobblerFunction:
         """
         pass
 
-    def helpbash(self, parser, args):
+    def helpbash(self, parser, args, print_options = True, print_subs = False):
         """
         Print out the arguments in an easily parseable format
         """
         # We only want to print either the subcommands available or the
         # options, but not both
         option_list = []
-        for sub in self.subcommands():
-            if sub.__str__() in args:
-                # Subcommand has already been entered so lets show the options
-                option_list = []
-                break
-            option_list.append(sub.__str__())
-        if not option_list:
+        if print_subs:
+            for sub in self.subcommands():
+                option_list.append(sub.__str__())
+        elif print_options:
             for opt in parser.option_list:
                 option_list.extend(opt.__str__().split('/'))
         print ' '.join(option_list)
@@ -204,8 +201,11 @@ class CobblerFunction:
                 break
         p = optparse.OptionParser(usage="cobbler %s [ARGS]" % accum)
         self.add_options(p, args)
-        if "--helpbash" in args:
-            self.helpbash(p, args)
+        if "--helpsubs" in args:
+            self.helpbash(p, args, False, True)
+            sys.exit(0)
+        elif "--helpopts" in args:
+            self.helpbash(p, args, True, False)
             sys.exit(0)
         # if using subcommands, ensure one and only one is used
         subs = self.subcommands()
diff --git a/config/cobbler_bash b/config/cobbler_bash
index 0de7e2a..9b55872 100644
--- a/config/cobbler_bash
+++ b/config/cobbler_bash
@@ -42,16 +42,28 @@ _cobbler()
     if [ -n "$special" ]
     then
 	# Take care of sub commands
-	SPECIALSUB_CMDS=`cobbler $special --helpbash | sed "s/ /|/g"`
-	for (( i=0; i < [EMAIL PROTECTED]; i++ )); do
-		if [[ ${COMP_WORDS[i]} == @(${SPECIALSUB_CMDS}) ]]; then
-			specialsub=${COMP_WORDS[i]}
-			break
-		fi
-	done
+	SPECIALSUB_CMDS=`cobbler $special --helpsubs | sed "s/ /|/g"`
+	if [ -n "${SPECIALSUB_CMDS}" ] ; then
+	    for (( i=0; i < [EMAIL PROTECTED]; i++ )); do
+		    if [[ ${COMP_WORDS[i]} == @(${SPECIALSUB_CMDS}) ]]; then
+			    specialsub=${COMP_WORDS[i]}
+			    break
+		    fi
+	    done
+	else
+	    # This command has no subcommands
+	    COMPREPLY=( $( compgen -f -W '$( cobbler $special --helpopts )' -- $cur ) )
+	    return 0
+	fi
 
-	COMPREPLY=( $( compgen -W '$( cobbler $special $specialsub --helpbash )' -- $cur ) )
-	return 0
+	if [ -n "$specialsub" ]
+	then
+	    COMPREPLY=( $( compgen -f -W '$( cobbler $special $specialsub --helpopts )' -- $cur ) )
+	    return 0
+	else
+	    COMPREPLY=( $( compgen -W '$( cobbler $special --helpsubs )' -- $cur ) )
+	    return 0
+	fi
     fi
 
     case $cur in
@@ -71,16 +83,6 @@ _cobbler()
 	1)
 	    COMPREPLY=( $( compgen -W '$( cobbler --helpbash )' -- $cur ) )
 	    ;;
-	*)
-	    case $prev in
-		distro|profile|repo|system|image)
-			COMPREPLY=( $( compgen -W 'add edit copy list rename remove report' -- $cur ) )
-			;;
-		*)
-		    _filedir
-		    ;;
-	    esac
-	    ;;
     esac
 }
 complete -F _cobbler cobbler
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler

Reply via email to