From dc136d89fb6b68bbf8bd7106c715452c7203ab73 Mon Sep 17 00:00:00 2001 From: shnavid Date: Wed, 7 Mar 2007 15:33:06 +0000 Subject: Allow passing multiple comma-separated plugin names to -n (--noplugin) and -o (--onlyplugin) options. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@90 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/sosreport | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sosreport b/src/sosreport index 63f0648d..3989ff0b 100755 --- a/src/sosreport +++ b/src/sosreport @@ -28,7 +28,7 @@ supplied for application-specific information import sys import os #import curses -from optparse import OptionParser +from optparse import OptionParser, Option import sos.policyredhat from sos.helpers import * from snack import * @@ -78,8 +78,21 @@ if os.getuid() != 0: # for debugging __raisePlugins__ = 1 +class SosOption (Option): + """Allow to specify comma delimited list of plugins""" + ACTIONS = Option.ACTIONS + ("extend",) + STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",) + TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",) + ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",) + + def take_action(self, action, dest, opt, value, values, parser): + if action == "extend": + lvalue = value.split(",") + values.ensure_value(dest, []).extend(lvalue) + else: + Option.take_action(self, action, dest, opt, value, values, parser) -__cmdParser__ = OptionParser() +__cmdParser__ = OptionParser(option_class=SosOption) __cmdParser__.add_option("-a", "--alloptions", action="store_true", \ dest="usealloptions", default=False, \ help="Use all options for loaded plugins") @@ -92,10 +105,10 @@ __cmdParser__.add_option("-g", "--gatheronly", action="store_true", \ __cmdParser__.add_option("-l", "--list-plugins", action="store_true", \ dest="listPlugins", default=False, \ help="list existing plugins") -__cmdParser__.add_option("-n", "--noplugin", action="append", \ +__cmdParser__.add_option("-n", "--noplugin", action="extend", \ dest="noplugins",\ help="list of plugins _not_ to load") -__cmdParser__.add_option("-o", "--onlyplugin", action="append", \ +__cmdParser__.add_option("-o", "--onlyplugin", action="extend", \ dest="onlyplugins",\ help="list of plugins to load") __cmdParser__.add_option("-v", "--verbose", action="count", \ -- cgit