()
| 12 | |
| 13 | |
| 14 | def main(): |
| 15 | parser = argparse.ArgumentParser( |
| 16 | description="Convert various file formats to markdown.", |
| 17 | prog="markitdown", |
| 18 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 19 | usage=dedent( |
| 20 | """ |
| 21 | SYNTAX: |
| 22 | |
| 23 | markitdown <OPTIONAL: FILENAME> |
| 24 | If FILENAME is empty, markitdown reads from stdin. |
| 25 | |
| 26 | EXAMPLE: |
| 27 | |
| 28 | markitdown example.pdf |
| 29 | |
| 30 | OR |
| 31 | |
| 32 | cat example.pdf | markitdown |
| 33 | |
| 34 | OR |
| 35 | |
| 36 | markitdown < example.pdf |
| 37 | |
| 38 | OR to save to a file use |
| 39 | |
| 40 | markitdown example.pdf -o example.md |
| 41 | |
| 42 | OR |
| 43 | |
| 44 | markitdown example.pdf > example.md |
| 45 | """ |
| 46 | ).strip(), |
| 47 | ) |
| 48 | |
| 49 | parser.add_argument( |
| 50 | "-v", |
| 51 | "--version", |
| 52 | action="version", |
| 53 | version=f"%(prog)s {__version__}", |
| 54 | help="show the version number and exit", |
| 55 | ) |
| 56 | |
| 57 | parser.add_argument( |
| 58 | "-o", |
| 59 | "--output", |
| 60 | help="Output file name. If not provided, output is written to stdout.", |
| 61 | ) |
| 62 | |
| 63 | parser.add_argument( |
| 64 | "-x", |
| 65 | "--extension", |
| 66 | help="Provide a hint about the file extension (e.g., when reading from stdin).", |
| 67 | ) |
| 68 | |
| 69 | parser.add_argument( |
| 70 | "-m", |
| 71 | "--mime-type", |
no test coverage detected
searching dependent graphs…