Skip to content

Commit

Permalink
added output to save
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraflame4 committed Apr 20, 2023
1 parent 45019ad commit 9ca8418
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions CliRenderer/__main__.py
Original file line number Diff line number Diff line change
@@ -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."),
Expand All @@ -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,
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9ca8418

Please sign in to comment.