Skip to content

Commit

Permalink
simple versioning tool
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Oct 24, 2014
1 parent 4471069 commit ffd7fcf
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
23 changes: 23 additions & 0 deletions elasticgit/commands/tests/test_version.py
@@ -0,0 +1,23 @@
from StringIO import StringIO
import json

from elasticgit import version_info
from elasticgit.tests.base import ToolBaseTest
from elasticgit.commands.version import VersionTool


class TestVersionTool(ToolBaseTest):

def test_dump_version_info(self):
tool = VersionTool()
tool.stdout = StringIO()
tool.run('the name', 'the license', 'the author', 'the author url')
self.assertEqual(
json.loads(tool.stdout.getvalue()),
{
'name': 'the name',
'license': 'the license',
'author': 'the author',
'author_url': 'the author url',
'version_info': version_info
})
37 changes: 37 additions & 0 deletions elasticgit/commands/version.py
@@ -0,0 +1,37 @@
import sys
import json

from elasticgit import version_info
from elasticgit.commands.base import ToolCommand, CommandArgument


class VersionTool(ToolCommand):

command_name = 'version'
command_help_text = ('Tools for versioning & version checking '
'a content repository')
command_arguments = (
CommandArgument(
'-n', '--name',
help='The name to give this repository', required=True),
CommandArgument(
'-l', '--license',
help='The license the publish this content under.', required=True),
CommandArgument(
'-a', '--author',
help='The author', required=True),
CommandArgument(
'-au', '--author-url',
help='The url where to find more information about the author'),
)

stdout = sys.stdout

def run(self, name, license, author, author_url=None):
json.dump({
'name': name,
'license': license,
'author': author,
'author_url': author_url,
'version_info': version_info,
}, fp=self.stdout, indent=2)
2 changes: 2 additions & 0 deletions elasticgit/tools.py
Expand Up @@ -3,6 +3,7 @@
from elasticgit.commands.avro import SchemaDumper, SchemaLoader
from elasticgit.commands.gitmodel import MigrateGitModelRepo
from elasticgit.commands.shell import EGShell
from elasticgit.commands.version import VersionTool


def add_command(subparsers, dispatcher_class): # pragma: no cover
Expand All @@ -23,6 +24,7 @@ def get_parser(): # pragma: no cover
add_command(subparsers, SchemaLoader)
add_command(subparsers, MigrateGitModelRepo)
add_command(subparsers, EGShell)
add_command(subparsers, VersionTool)

return parser

Expand Down

0 comments on commit ffd7fcf

Please sign in to comment.