Skip to content
Snippets Groups Projects
Commit 4fa41467 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Command-line interface: deduce language from extension of input file

parent d21e4963
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ def main():
parser.add_argument("infile")
parser.add_argument("outfile")
parser.add_argument("--lang", default="loopy")
parser.add_argument("--lang")
parser.add_argument("--target")
parser.add_argument("--name")
parser.add_argument("--transform")
......@@ -65,13 +65,28 @@ def main():
from warnings import warn
warn("--target option is deprecated and ignored")
lang = None
if args.infile == "-":
infile_content = sys.stdin.read()
else:
from os.path import splitext
_, ext = splitext(args.infile)
lang = {
".loopy": "loopy",
".floopy": "fortran",
}
with open(args.infile, "r") as infile_fd:
infile_content = infile_fd.read()
if args.lang == "loopy":
if args.lang is not None:
lang = args.lang
if lang is None:
raise RuntimeError("unable to deduce input language "
"(wrong input file extension? --lang flag?)")
if lang == "loopy":
# {{{ path wrangling
from os.path import dirname, abspath
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment