From 68030e1d69277478b145ff6ca004e609ebe2d044 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Fri, 21 Aug 2015 10:04:55 -0500 Subject: [PATCH] Make output file optional in command line tool --- bin/loopy | 14 ++++++++++---- examples/fortran/run-floopy.sh | 6 ------ examples/fortran/run-loopy.sh | 3 --- 3 files changed, 10 insertions(+), 13 deletions(-) delete mode 100755 examples/fortran/run-floopy.sh delete mode 100755 examples/fortran/run-loopy.sh diff --git a/bin/loopy b/bin/loopy index 8f365c7be..c8cbea1c6 100644 --- a/bin/loopy +++ b/bin/loopy @@ -50,8 +50,9 @@ def main(): parser = ArgumentParser(description="Stand-alone loopy frontend") - parser.add_argument("infile") - parser.add_argument("outfile") + parser.add_argument("infile", metavar="INPUT_FILE") + parser.add_argument("outfile", default="-", metavar="OUTPUT_FILE", + help="Defaults to stdout ('-').", nargs='?') parser.add_argument("--lang", metavar="LANGUAGE", help="loopy|fortran") parser.add_argument("--target") parser.add_argument("--name") @@ -185,10 +186,15 @@ def main(): code, impl_arg_info = generate_code(kernel) codes.append(code) - if args.outfile == "-": + if args.outfile: + outfile, = args.outfile + else: + outfile = "-" + + if outfile == "-": sys.stdout.write("\n\n".join(codes)) else: - with open(args.outfile, "w") as outfile_fd: + with open(outfile, "w") as outfile_fd: outfile_fd.write("\n\n".join(codes)) diff --git a/examples/fortran/run-floopy.sh b/examples/fortran/run-floopy.sh deleted file mode 100755 index fcea2c8b5..000000000 --- a/examples/fortran/run-floopy.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -NAME="$1" -shift - -python $(which loopy) --lang=fpp "$NAME" - "$@" diff --git a/examples/fortran/run-loopy.sh b/examples/fortran/run-loopy.sh deleted file mode 100755 index f22f78424..000000000 --- a/examples/fortran/run-loopy.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -python $(which loopy) --lang=loopy "$NAME" - "$@" -- GitLab