[Yum-devel] [PATCH]: allow plugins to add new commands to the cli

Menno Smits menno-yum at freshfoo.com
Thu Sep 14 05:44:55 UTC 2006


Hey Bastiaan,

Bastiaan Bakker wrote:
 >
 > I've attached an updated patch that uses the YumCommand object 
approach. The
 > result may be a bit more verbose, but looks a lot cleaner IMHO.
 >
 > A plugin would use it like this:
 >
 > class FooBarCommand(cli.YumCommand):
 >     def getNames(self):
 >         return ['foobar', 'foo-bar']
 >
 >     def doCheck(self, base):
 >         cli.checkRootUID(base)
 >
 >     def doCommand(self, base):
 >         return 0, ['nothing to do for foobar']
 >
 > def config_hook(conduit):
 >     conduit.registerCommand(FooBarCommand())
 >

The "command as a class" idea isn't bad.

How about passing the command name to doCommand and doCheck
rather than relying on base.basecmd? This aids testability and
clarity. I can see basecmd going away in the future.

Menno



More information about the Yum-devel mailing list