diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-10-11 10:04:46 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-10-11 10:04:46 +0200 |
commit | c968a0cee7ae6980fe4e15757b3eae10f4369a2f (patch) | |
tree | c08e7a9434d1af7d1b8c2f85737d66b7b6dd9c96 /src | |
parent | error fixes (diff) | |
download | gpp-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.py | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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') |