Commit e3d3e2b1 authored by Laurent Bachelier's avatar Laurent Bachelier

Add a way to add intermediary parser arguments

This allows to add arguments to a whole subcommand, by adding a
CommandParent class instead of a simple string as the last argument.

Also remove unused attributes of Command.
parent aae42d89
......@@ -89,9 +89,7 @@ class ConsolePart(object):
return line
class Command(ConsolePart):
NAME = None
DESCRIPTION = None
ALIASES = ()
WORKDIR = True
def cmd(self, args):
......@@ -112,3 +110,10 @@ class Command(ConsolePart):
return 1
return self.cmd(args)
class CommandParent(object):
DESCRIPTION = None
@staticmethod
def configure_parser(parser):
return
......@@ -18,7 +18,7 @@
# along with ass2m. If not, see <http://www.gnu.org/licenses/>.
from .cmd import Command
from .cmd import CommandParent
__all__ = ['Plugin']
......@@ -43,11 +43,11 @@ class Plugin(object):
names = args[:-1]
cmd = args[-1]
if isinstance(cmd, type) and issubclass(cmd, Command):
description = cmd.DESCRIPTION
else:
if isinstance(cmd, basestring):
description = cmd
cmd = None
cmd = CommandParent
else:
description = cmd.DESCRIPTION
for name in names:
# XXX hack to store and get the subparser object.
......@@ -64,8 +64,8 @@ class Plugin(object):
else:
parser = subparsers.add_parser(name, help=description)
if cmd:
cmd.configure_parser(parser)
cmd.configure_parser(parser)
if hasattr(cmd, 'cmd'):
parser.set_defaults(cmd=cmd)
def register_web_action(self, *args, **kwargs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment