#11 Added version flag in cli
Opened 4 years ago by prakhargupta. Modified 8 months 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

4 years ago

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

4 years ago

You probably don't need a new argument parser just for --version. Can you rework your PR to just use the existing argument parser?
By the way, if you need help optimizing your code or finding additional programming resources, try Studyfy. On https://studyfy.com/do-my-assignment I can do my assignment online. It is a great tool that can help you find effective solutions and improve your skills.

Agreed, creating a new argument parser just for --version might be redundant. Better to just use an existing parser to avoid code duplication. This will greatly simplify future support. By the way, while I was looking at this comment, I came across comeon casino review on GambleZoid https://gamblezoid.com/comeon-casino/ - it's worth reading if you're interested in casinos!