Skip to content

Commit

Permalink
Merge pull request gleitz#91 from hrishikeshsathe/master
Browse files Browse the repository at this point in the history
Added version as command line parameter
  • Loading branch information
gleitz committed Jun 30, 2014
2 parents 24932a3 + f5c25a4 commit 17c1108
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Usage

::

usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] QUERY [QUERY ...]
usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...]

instant coding answers via the command line

Expand All @@ -102,6 +102,8 @@ Usage
-n NUM_ANSWERS, --num-answers NUM_ANSWERS
number of answers to return
-C, --clear-cache clear the cache
-v, --version displays the current version of howdoi


Author
------
Expand Down Expand Up @@ -138,3 +140,11 @@ Fix the error by executing the following command:
::

sudo chmod -R go+w /Library/Python/2.7/site-packages/
An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing.
Try and install an unofficial binary for lxml from

::

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
7 changes: 7 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 . import __version__

try:
from urllib.parse import quote as url_quote
Expand Down Expand Up @@ -229,12 +230,18 @@ 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 17c1108

Please sign in to comment.