Skip to content

Commit ff834e2

Browse files
author
Jonathan Como
committed
Add an option for the version
1 parent c04de01 commit ff834e2

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from setuptools import setup, find_packages
44
from setuptools.command.test import test as TestCommand
55

6+
from snake.version import VERSION
7+
68

79
class Tox(TestCommand):
810
user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
@@ -31,7 +33,7 @@ def run_tests(self):
3133

3234
setup(
3335
name = 'snaketool',
34-
version = '0.1.0',
36+
version = VERSION,
3537
description = "An easy to use build script utility",
3638
url = 'https://github.com/jcomo/snake',
3739
author = 'Jonathan Como',

snake/application.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .parser import ApplicationArgsParser as parser
88
from .shell import ShellWrapper
99
from .tasks import TaskRegistry, NoSuchTaskException
10+
from .version import VERSION
1011

1112

1213
class Application(object):
@@ -23,6 +24,9 @@ def error(self, message):
2324

2425
def run(self):
2526
tasks, args, opts = parser.parse(argv[1:])
27+
if opts.version:
28+
self.info('snake, version %s' % VERSION)
29+
return
2630

2731
try:
2832
self._run(tasks, args, opts)

snake/parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from optparse import OptionParser
22

33
flags_parser = OptionParser()
4-
flags_parser.add_option('-T', '--tasks', dest='show_tasks', action='store_true',
5-
help="Display the tasks with descriptions and exits")
6-
flags_parser.add_option('-t', '--trace', dest='trace', action='store_true',
7-
help="Turn on verbose backtraces")
84
flags_parser.add_option('-f', '--snakefile', dest='filename', metavar='FILE',
95
help="Use FILE as the Snakefile")
6+
flags_parser.add_option('-t', '--trace', dest='trace', action='store_true',
7+
help="Turn on verbose backtraces")
8+
flags_parser.add_option('-T', '--tasks', dest='show_tasks', action='store_true',
9+
help="Display the tasks with descriptions and exit")
10+
flags_parser.add_option('--version', dest='version', action='store_true',
11+
help="Display the version information and exit")
1012

1113

1214
class ApplicationArgsParser(object):

snake/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION = '0.1.1'

tests/snake_tests.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33

44
class SnakeTests(IntegrationTest):
5+
def test_it_reports_version_information(self):
6+
result = self.execute('snake --version')
7+
8+
self.assertStderrEmpty(result)
9+
self.assertStdoutMatches(result, r'^snake, version \d+\.\d+\.\d+$')
10+
self.assertStatusEqual(result, 0)
11+
512
def test_it_exits_with_error_when_no_snakefile_found(self):
613
result = self.execute('snake')
714

0 commit comments

Comments
 (0)