Skip to content

Commit

Permalink
Added version as command line parameter
Browse files Browse the repository at this point in the history
Use -v or --version shows the version as in __init__.py
  • Loading branch information
Hrishikesh Sathe committed Jun 27, 2014
1 parent 24932a3 commit c5fa716
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions howdoi/howdoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import requests
import requests_cache
import sys
from __init__ import __version__

try:
from urllib.parse import quote as url_quote
Expand Down Expand Up @@ -229,12 +230,17 @@ def get_parser():
parser.add_argument('-n','--num-answers', help='number of answers to return', default=1, type=int)
parser.add_argument('-C','--clear-cache', help='clear the cache',
action='store_true')
parser.add_argument('-v','--version',help='displays the current version of howdoi',action='store_true')
return parser


def command_line_runner():
parser = get_parser()
args = vars(parser.parse_args())

if args['version']:
print(__version__)
return

if args['clear_cache']:
clear_cache()
Expand Down

0 comments on commit c5fa716

Please sign in to comment.