summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsaucypy9
1 files changed, 7 insertions, 2 deletions
diff --git a/saucypy b/saucypy
index 745e93d..f24fcab 100755
--- a/saucypy
+++ b/saucypy
@@ -3,6 +3,7 @@
import difflib
import json
import optparse
+import shlex
import sys
VERSION = "1.0.0"
@@ -13,11 +14,14 @@ def find( key, entries ):
return difflib.get_close_matches( key, entries.keys() )
def parse_args():
- parser = optparse.OptionParser()
+ args = sys.argv[1:]
+ if not args:
+ args = shlex.split( sys.stdin.read() )
+ parser = optparse.OptionParser( usage = "!source <term> | !source --add <key> <value>" )
parser.add_option( "-a", "--add", action = "store", nargs = 2 )
parser.add_option( "-i", "--index", action = "store", type = int )
parser.add_option( "-v", "--version", action = "store_true" )
- return parser.parse_args()
+ return parser.parse_args( args )
def main():
options, args = parse_args()
@@ -58,3 +62,4 @@ def main():
if __name__ == "__main__":
main()
+