-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add version option to markitdown CLI (#172)
Add a `--version` option to the markitdown command-line interface that displays the current version number.
- Loading branch information
Showing
1 changed file
with
20 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
# SPDX-FileCopyrightText: 2024-present Adam Fourney <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
import sys | ||
import argparse | ||
import sys | ||
from textwrap import dedent | ||
from .__about__ import __version__ | ||
from ._markitdown import MarkItDown, DocumentConverterResult | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="Convert various file formats to markdown.", | ||
prog="markitdown", | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
usage=dedent( | ||
""" | ||
SYNTAX: | ||
SYNTAX: | ||
markitdown <OPTIONAL: FILENAME> | ||
If FILENAME is empty, markitdown reads from stdin. | ||
EXAMPLE: | ||
markitdown example.pdf | ||
OR | ||
cat example.pdf | markitdown | ||
OR | ||
OR | ||
markitdown < example.pdf | ||
OR to save to a file use | ||
|
@@ -41,6 +43,14 @@ def main(): | |
).strip(), | ||
) | ||
|
||
parser.add_argument( | ||
"-v", | ||
"--version", | ||
action="version", | ||
version=f"%(prog)s {__version__}", | ||
help="show the version number and exit", | ||
) | ||
|
||
parser.add_argument("filename", nargs="?") | ||
parser.add_argument( | ||
"-o", | ||
|