Skip to content

Commit 06765ce

Browse files
committed
✨ allow getting ocr return in CLI
1 parent 3051e66 commit 06765ce

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

mindee/__main__.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def call_endpoint(args):
8787
if args.product_name == "custom":
8888
parsed_data = doc_to_parse.parse(doc_type, username=args.username)
8989
else:
90-
parsed_data = doc_to_parse.parse(doc_type)
90+
parsed_data = doc_to_parse.parse(doc_type, include_words=args.include_words)
9191

9292
if args.output_type == "raw":
9393
print(json.dumps(parsed_data.http_response, indent=2))
@@ -134,28 +134,35 @@ def parse_args():
134134
dest="%s_api_key" % key_name,
135135
help="API key for %s document endpoint" % key_name,
136136
)
137+
subp.add_argument(
138+
"-w",
139+
"--with-words",
140+
dest="include_words",
141+
action="store_true",
142+
help="Include words in response",
143+
)
137144
subp.add_argument(
138145
"-i",
139146
"--input-type",
140147
dest="input_type",
141148
choices=["path", "file", "base64", "bytes"],
142149
default="path",
143-
help="Specify how to handle the input,\n"
144-
"path: open a path (default).\n"
145-
"file: open as a file handle.\n"
146-
"base64: load the from a base64 encoded text file.\n"
147-
"bytes: load the contents as raw bytes.",
150+
help="Specify how to handle the input.\n"
151+
"- path: open a path (default).\n"
152+
"- file: open as a file handle.\n"
153+
"- base64: load the from a base64 encoded text file.\n"
154+
"- bytes: load the contents as raw bytes.",
148155
)
149156
subp.add_argument(
150157
"-o",
151158
"--output-type",
152159
dest="output_type",
153160
choices=["summary", "raw", "parsed"],
154161
default="summary",
155-
help="Specify how to output the data,\n"
156-
"summary: a basic summary (default)\n"
157-
"raw: the raw HTTP response\n"
158-
"parsed: the validated and parsed data fields\n",
162+
help="Specify how to output the data.\n"
163+
"- summary: a basic summary (default)\n"
164+
"- raw: the raw HTTP response\n"
165+
"- parsed: the validated and parsed data fields\n",
159166
)
160167
subp.add_argument(
161168
"-C",
@@ -175,9 +182,6 @@ def parse_args():
175182
subp.add_argument(dest="path", help="Full path to the file")
176183

177184
parsed_args = parser.parse_args()
178-
if not parsed_args.product_name:
179-
parser.print_help()
180-
sys.exit(1)
181185
return parsed_args
182186

183187

tests/test_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def custom_doc(monkeypatch):
1919
cut_pdf=True,
2020
input_type="path",
2121
output_type="summary",
22+
include_words=False,
2223
path="./tests/data/license_plates/plate.png",
2324
)
2425

@@ -34,6 +35,7 @@ def invoice_doc(monkeypatch):
3435
cut_pdf=True,
3536
input_type="path",
3637
output_type="summary",
38+
include_words=False,
3739
path="./tests/data/invoices/invoice.pdf",
3840
)
3941

0 commit comments

Comments
 (0)