From b58cc00e34155501f8e77dc6cb3e086fdbb02c59 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 17 Dec 2024 05:51:30 +0000 Subject: [PATCH] slight tidy - follow-up to #46 --- src/markitdown/__main__.py | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/markitdown/__main__.py b/src/markitdown/__main__.py index 2d53173..2c21845 100644 --- a/src/markitdown/__main__.py +++ b/src/markitdown/__main__.py @@ -10,37 +10,19 @@ def main(): parser = argparse.ArgumentParser( description="Convert various file formats to markdown.", formatter_class=argparse.RawDescriptionHelpFormatter, - usage=""" -SYNTAX: - - markitdown - If FILENAME is empty, markitdown reads from stdin. - -EXAMPLE: - - markitdown example.pdf - - OR - - cat example.pdf | markitdown - - OR - - markitdown < example.pdf -""".strip(), + epilog="""examples: + markitdown example.pdf + cat example.pdf | markitdown + markitdown < example.pdf""", ) - parser.add_argument("filename", nargs="?") + parser.add_argument( + "filename", nargs="?", help="if unspecified, defaults to stdin" + ) args = parser.parse_args() - - if args.filename is None: - markitdown = MarkItDown() - result = markitdown.convert_stream(sys.stdin.buffer) - print(result.text_content) - else: - markitdown = MarkItDown() - result = markitdown.convert(args.filename) - print(result.text_content) + markitdown = MarkItDown() + result = markitdown.convert(args.filename or sys.stdin.buffer) + print(result.text_content) if __name__ == "__main__":