Skip to content

Commit

Permalink
Add a base Command object defining core command behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
mblayman committed Jan 3, 2016
1 parent 543f3ad commit b7cf2cf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions handroll/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2016, Matt Layman

from .base import Command # NOQA
13 changes: 13 additions & 0 deletions handroll/commands/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2016, Matt Layman


class Command(object):
"""A command class with the minimal interface required for each command."""

@classmethod
def register(cls, parser):
"""Register required options.
The provided parser is a subparser from ``subparsers.add_parser``.
"""
raise NotImplementedError()
13 changes: 13 additions & 0 deletions handroll/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2016, Matt Layman

import mock

from handroll.commands import Command
from handroll.tests import TestCase


class TestCommand(TestCase):

def test_register_not_implemented(self):
parser = mock.Mock()
self.assertRaises(NotImplementedError, Command.register, parser)

0 comments on commit b7cf2cf

Please sign in to comment.