Skip to content

Commit

Permalink
feat(cli): added output format "text"
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTheFactory committed Nov 21, 2023
1 parent 6485c40 commit 31b9079
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion newspaper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_arparse() -> argparse.ArgumentParser:
parser.add_argument(
"--output-format",
"-of",
choices=["csv", "json"],
choices=["csv", "json", "text"],
default="json",
help="The output format of the parsed article.",
)
Expand Down Expand Up @@ -228,6 +228,9 @@ def csv_string(article_dict: dict) -> str:
if idx == 0:
write_output(csv_header())
write_output(csv_string(output))
elif args.output_format == "text":
write_output(f"{article.title}\n\n")
write_output(article.text)
else:
raise ValueError(f"Unknown output format: {args.output_format}")

Expand Down

0 comments on commit 31b9079

Please sign in to comment.