#11 Added version flag in cli
Opened 3 years ago by prakhargupta. Modified 3 years ago
prakhargupta/fedora-business-cards version  into  master

@@ -26,5 +26,10 @@ 

  

  from pkg_resources import get_distribution, DistributionNotFound

  

- __version__ = '1.beta1'

+ """

+ fedora-business-cards package version.

+ 

+ NOTE: Version string defined here will be picked by setup.py automatically.  

+ """

+ __version__ = '2.2.1'

  __all__ = ('common', 'export', 'frontend', 'generators')

@@ -31,13 +31,17 @@ 

  from fedora_business_cards import export  # hah

  from fedora_business_cards import generators

  

- 

  def main():

      """

      Call this to make things happen.

      """

      # Setup option parser

      parser = argparse.ArgumentParser()

+ 

+     # Version

+     version_parser = argparse.ArgumentParser()

+     version_parser.add_argument("--version", dest="version", action="store_true", help="print version information")

+ 

      # General options

      parser.add_argument("--list-generators", dest="showgen", default=False,

                          action="store_true", help="display list of generators")
@@ -87,6 +91,12 @@ 

          except ImportError:

              pass

  

+     # version information

+     opts = version_parser.parse_args()

+     if opts.version:

+         print(common.__version__)

+         sys.exit()

+ 

      # Parse arguments

      options = parser.parse_args()

  

file modified
+7 -1
@@ -1,8 +1,14 @@ 

  from setuptools import setup, find_packages

+ import re, io

+ 

+ __version__ = re.search(

+     r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]',

+     io.open('fedora_business_cards/__init__.py', encoding='utf_8_sig').read()

+     ).group(1)

  

  setup(

      name = 'fedora-business-cards',

-     version = '2.2',

+     version = __version__,

      packages = find_packages(),

  

      author = 'Brian Exelbierd',

  • Added --version in CLI to display the version number.

Sorry for the delay in reviewing!

You probably don't need a new argument parser just for --version -- can you rework your PR to just reuse the existing argument parser?

Metadata Update from @salimma:
- Request assigned

3 years ago

Metadata Update from @salimma:
- Pull-request tagged with: change-requested

3 years ago