Skip to content
Browse files

Add ability to just pass in a command class instead of an instance.

  • Loading branch information...
1 parent be512d3 commit 10755500972fb765c7449423029d2d46a7960b34 @mehcode mehcode committed Oct 5, 2013
Showing with 10 additions and 0 deletions.
  1. +3 −0 flask_script/__init__.py
  2. +7 −0 tests.py
View
3 flask_script/__init__.py
@@ -205,6 +205,9 @@ def add_command(self, *args, **kwargs):
if isinstance(command, Manager):
command.parent = self
+ if isinstance(command, type):
+ command = command()
+
namespace = kwargs.get('namespace')
if not namespace:
namespace = getattr(command, 'namespace', None)
View
7 tests.py
@@ -228,6 +228,13 @@ def test_add_namespaced_simple_command(self):
assert isinstance(ns._commands['hello'], SimpleCommand)
assert isinstance(ns._commands['world'], SimpleCommand)
+ def test_add_command_class(self):
+
+ manager = Manager(self.app)
+ manager.add_command('simple', SimpleCommand)
+
+ assert isinstance(manager._commands['simple'], SimpleCommand)
+
def test_simple_command_decorator(self, capsys):
manager = Manager(self.app)

0 comments on commit 1075550

Please sign in to comment.
Something went wrong with that request. Please try again.