summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xwikiquery12
1 files changed, 10 insertions, 2 deletions
diff --git a/wikiquery b/wikiquery
index 1d7b129..627a0ee 100755
--- a/wikiquery
+++ b/wikiquery
@@ -1,26 +1,34 @@
#! /usr/bin/env python
import argparse
+import sys
import wikipedia
+version = "0.0.1"
+
def parse_args():
parser = argparse.ArgumentParser()
- parser.add_argument("topic", nargs=1)
+ parser.add_argument("topic", nargs="*")
parser.add_argument("--search", action="store_true")
parser.add_argument("--url", action="store_true")
+ parser.add_argument("-v", "--version", action="store_true")
return parser.parse_args()
def main():
args = parse_args()
+
+ if args.version:
+ print version
+ sys.exit(0)
if args.search:
print wikipedia.search(args.topic)
elif args.url:
page = wikipedia.page(args.topic)
print page.url
- else:
+ elif args.topic:
print wikipedia.summary(args.topic)
if __name__ == "__main__":