11import argparse
22from argparse import Namespace
33import json
4- import sys
54from typing import Dict
65
76from mindee import Client
@@ -87,7 +86,7 @@ def call_endpoint(args):
8786 if args .product_name == "custom" :
8887 parsed_data = doc_to_parse .parse (doc_type , username = args .username )
8988 else :
90- parsed_data = doc_to_parse .parse (doc_type )
89+ parsed_data = doc_to_parse .parse (doc_type , include_words = args . include_words )
9190
9291 if args .output_type == "raw" :
9392 print (json .dumps (parsed_data .http_response , indent = 2 ))
@@ -134,28 +133,35 @@ def parse_args():
134133 dest = "%s_api_key" % key_name ,
135134 help = "API key for %s document endpoint" % key_name ,
136135 )
136+ subp .add_argument (
137+ "-w" ,
138+ "--with-words" ,
139+ dest = "include_words" ,
140+ action = "store_true" ,
141+ help = "Include words in response" ,
142+ )
137143 subp .add_argument (
138144 "-i" ,
139145 "--input-type" ,
140146 dest = "input_type" ,
141147 choices = ["path" , "file" , "base64" , "bytes" ],
142148 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." ,
149+ help = "Specify how to handle the input. \n "
150+ "- path: open a path (default).\n "
151+ "- file: open as a file handle.\n "
152+ "- base64: load the from a base64 encoded text file.\n "
153+ "- bytes: load the contents as raw bytes." ,
148154 )
149155 subp .add_argument (
150156 "-o" ,
151157 "--output-type" ,
152158 dest = "output_type" ,
153159 choices = ["summary" , "raw" , "parsed" ],
154160 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 " ,
161+ help = "Specify how to output the data. \n "
162+ "- summary: a basic summary (default)\n "
163+ "- raw: the raw HTTP response\n "
164+ "- parsed: the validated and parsed data fields\n " ,
159165 )
160166 subp .add_argument (
161167 "-C" ,
@@ -175,9 +181,6 @@ def parse_args():
175181 subp .add_argument (dest = "path" , help = "Full path to the file" )
176182
177183 parsed_args = parser .parse_args ()
178- if not parsed_args .product_name :
179- parser .print_help ()
180- sys .exit (1 )
181184 return parsed_args
182185
183186
0 commit comments