@@ -344,7 +344,10 @@ def process(resources, processor, fields):
344344@click .argument ("input" , required = True , type = click .File (mode = "r" , encoding = "utf-8" ))
345345@click .option (
346346 "--fields" , "-f" , required = False , multiple = True
347- ) # TODO: add list of supported fields
347+ )
348+ @click .option (
349+ "--exclude" , "-e" , required = False , multiple = True , default = [],
350+ )
348351@click .option (
349352 "--output" , "-o" , required = True , type = click .File (mode = "w" , encoding = "utf-8" )
350353)
@@ -356,7 +359,7 @@ def process(resources, processor, fields):
356359 help = "Format of output" ,
357360)
358361@click .pass_context
359- def batch (ctx , input , fields , output , format ):
362+ def batch (ctx , input , fields , output , format , exclude ):
360363 """
361364 Batch command for doing fast bulk processing.
362365
@@ -373,6 +376,15 @@ def batch(ctx, input, fields, output, format):
373376 )
374377 return
375378
379+ # enforce mutual exclusivity of fields and exclude
380+ if exclude and fields :
381+ raise click .ClickException ("'--fields / -f' and '--exclude / -e' are mutually exclusive." )
382+
383+ # if the user wants to exclude some fields, get all the fields in fields that are not in exclude
384+ if exclude :
385+ fields = set (ipdata .valid_fields ).difference (set (exclude ))
386+
387+
376388 # Prepare requests
377389 ipdata = IPData (ctx .obj ["api-key" ])
378390 resources = [resource .strip () for resource in input .readlines ()]
0 commit comments