Click's built in support for version option 83/27383/4
authorTaseer Ahmed <taseer94@gmail.com>
Mon, 23 Jan 2017 13:41:58 +0000 (18:41 +0500)
committerTaseer Ahmed <taseer94@gmail.com>
Mon, 23 Jan 2017 14:43:14 +0000 (19:43 +0500)
Change-Id: I62ffde066fe2fcb5be7af9a29686a7d380353670
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
qtip/cli/entry.py
tests/unit/cli/test_options.py

index 0ecb06c..9f51f25 100644 (file)
@@ -22,7 +22,6 @@ class Context(object):
     def __init__(self):
         self.verbose = False
         self.debug = False
-        self.version = 'qtip-1.0.0'
 
     def log(self, msg, *args):
         ''' Log message to stderr '''
@@ -32,10 +31,6 @@ class Context(object):
         ''' Log message to stderr when verbose '''
         pass
 
-    def version(self):
-        ''' Display programs version '''
-        pass
-
     def debug(self, msg, *args):
         ''' Log message to debug '''
         pass
@@ -72,7 +67,7 @@ class QtipCli(click.MultiCommand):
                invoke_without_command=True)
 @click.option('-v', '--verbose', is_flag=True, help='Enable verbose mode.')
 @click.option('-d', '--debug', is_flag=True, help='Enable debug mode.')
-@click.option('--version', is_flag=True, help='Shows program current version.')
+@click.version_option('dev')
 @pass_context
-def cli(ctx, verbose, version, debug):
+def cli(ctx, verbose, debug):
     pass
index 5129b5c..f947281 100644 (file)
@@ -25,7 +25,7 @@ class TestClass(object):
 
     def test_version(self, runner):
         result = runner.invoke(cli, ['--version'])
-        assert '' in result.output
+        assert 'dev' in result.output
 
     def test_debug(self, runner):
         result = runner.invoke(cli, ['-d'])