@@ -348,7 +348,7 @@ def decompress(data):
348348 return b"" .join (all_blocks )
349349
350350
351- def main ():
351+ def _argument_parser ():
352352 parser = argparse .ArgumentParser ()
353353 parser .description = (
354354 "A simple command line interface for the igzip module. "
@@ -371,9 +371,11 @@ def main():
371371 "-3" , "--best" , action = "store_const" , dest = "compresslevel" ,
372372 const = _COMPRESS_LEVEL_BEST ,
373373 help = "use compression level 3 (best)" )
374+ compress_group .set_defaults (compress = True )
374375 compress_group .add_argument (
375- "-d" , "--decompress" , action = "store_false " ,
376+ "-d" , "--decompress" , action = "store_const " ,
376377 dest = "compress" ,
378+ const = False ,
377379 help = "Decompress the file instead of compressing." )
378380 parser .add_argument ("-c" , "--stdout" , action = "store_true" ,
379381 help = "write on standard output" )
@@ -383,7 +385,11 @@ def main():
383385 parser .add_argument ("-b" , "--buffer-size" ,
384386 default = 32 * 1024 , type = int ,
385387 help = argparse .SUPPRESS )
386- args = parser .parse_args ()
388+ return parser
389+
390+
391+ def main ():
392+ args = _argument_parser ().parse_args ()
387393
388394 compresslevel = args .compresslevel or _COMPRESS_LEVEL_TRADEOFF
389395
0 commit comments