From 9ca8418a614831a3b47105b516bd906ae9b7fa80 Mon Sep 17 00:00:00 2001 From: ultraflame42 <34125174+ultraflame4@users.noreply.github.com> Date: Thu, 20 Apr 2023 16:23:38 +0800 Subject: [PATCH] added output to save --- CliRenderer/__main__.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/CliRenderer/__main__.py b/CliRenderer/__main__.py index 9a0e8e9..2ae282d 100644 --- a/CliRenderer/__main__.py +++ b/CliRenderer/__main__.py @@ -1,14 +1,11 @@ -import json -import sys from pathlib import Path import typer as typer from PIL import Image from rich.console import Console import imageio as iio -from rich.progress import track from io import StringIO -from CliRenderer import render, Flags, render_frames +from CliRenderer import render, Flags def cli_main(source: Path = typer.Argument(..., help="The path to source image."), @@ -19,7 +16,7 @@ def cli_main(source: Path = typer.Argument(..., help="The path to source image." help="Automatically sets the output size to fit the terminal. Overrides --width and --height. Only works on supported terminals."), output: Path = typer.Option(None, "--out", "-o", - help="Saves the output to a file."), + help="Saves the output to a file. (Written as bytes)"), debug: bool = typer.Option(False, help="Enables debug mode. This will save the intermediate images to the build folder."), bg_intensity: float = typer.Option(1.0, "--bg-intensity", "-bgi", min=0.0, max=1.0, @@ -48,10 +45,11 @@ def cli_main(source: Path = typer.Argument(..., help="The path to source image." if output is not None: typer.echo(f"Saving output to {output}...") output.parent.mkdir(parents=True, exist_ok=True) - with open(output, "w") as f: - f.write(string) + with open(output, "wb") as f: + f.write(string.encode("utf-16")) print(string) + print(f"Saved output to {output}... Read it using `cat {output}`") def main(): typer.run(cli_main)