diff --git a/formatscaper/formatscaper.py b/formatscaper/formatscaper.py index 63aada14d8de03791f75b3016ea257bab20fc824..7840737025bbbeae2d5827fc3f5ba0f815b872f6 100755 --- a/formatscaper/formatscaper.py +++ b/formatscaper/formatscaper.py @@ -90,6 +90,12 @@ parser.add_argument( action="store_true", help="disable the progress bar", ) +parser.add_argument( + "--tempdir", + "-t", + default=None, + help="set directory for storing temporary files", +) args = parser.parse_args() @@ -165,6 +171,17 @@ if (num_threads := args.parallel) <= 0: if os.environ.get("TERM") == "foot": os.environ["TERM"] = "xterm" +# set the directory for storing temporary files +if args.tempdir: + if os.path.exists(args.tempdir): + os.environ["TMPDIR"] = os.environ["TMP"] = args.tempdir + else: + print( + "WARN: ignoring tempdir as it does not exist:", + args.tempdir, + file=sys.stderr, + ) + # set up variables required in the collection of results all_results = []