aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-10-11 10:04:46 +0200
committerMattias Andrée <maandree@operamail.com>2013-10-11 10:04:46 +0200
commitc968a0cee7ae6980fe4e15757b3eae10f4369a2f (patch)
treec08e7a9434d1af7d1b8c2f85737d66b7b6dd9c96
parenterror fixes (diff)
downloadgpp-c968a0cee7ae6980fe4e15757b3eae10f4369a2f.tar.gz
gpp-c968a0cee7ae6980fe4e15757b3eae10f4369a2f.tar.bz2
gpp-c968a0cee7ae6980fe4e15757b3eae10f4369a2f.tar.xz
parse command line
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/gpp.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gpp.py b/src/gpp.py
index 5828a7b..827720a 100644
--- a/src/gpp.py
+++ b/src/gpp.py
@@ -8,6 +8,23 @@ encoding = 'utf-8'
input_file = '/dev/stdin'
output_file = '/dev/stdout'
+for i in range(1, len(sys.argv)):
+ arg = sys.argv[i]
+ i += 1
+ if arg in ('-s', '--symbol'): symbol = sys.argv[i]
+ elif arg in ('-e', '--encoding'): encoding = sys.argv[i]
+ elif arg in ('-i', '--input'): input_file = sys.argv[i]
+ elif arg in ('-o', '--output'): output_file = sys.argv[i]
+ elif arg in ('-f', '--file'):
+ input_file = sys.argv[i]
+ output_file = sys.argv[i]
+ else:
+ continue
+ i += 1
+
+if input_file == '-': input_file = '/dev/stdin'
+if output_file == '-': output_file = '/dev/stdout'
+
data = None
with open(input_file, 'rb') as file:
data = file.read().decode(encoding, 'error').split('\n')