Skip to content

Commit 493f14f

Browse files
committed
Working gzip application
1 parent 1ae56eb commit 493f14f

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/isal/igzip.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,30 @@ def main():
231231
"A simple command line interface for the igzip module. "
232232
"Acts like igzip.")
233233
parser.add_argument("file")
234-
parser.add_argument("--fast", action="store_true",
235-
help="use fastest compression")
236-
parser.add_argument("--best", action="store_true",
237-
help="use best compression")
238-
parser.add_argument("-d", "--decompress", action="store_false",
239-
dest="compress",
240-
help="Decompress the file instead of compressing.")
234+
compress_group = parser.add_mutually_exclusive_group()
235+
compress_group.add_argument(
236+
"-0", "--fast", action="store_const", dest="compresslevel",
237+
const=_COMPRESS_LEVEL_FAST,
238+
help="use compression level 0 (fastest)")
239+
compress_group.add_argument(
240+
"-1", action="store_const", dest="compresslevel",
241+
const=1,
242+
help="use compression level 1")
243+
compress_group.add_argument(
244+
"-2", action="store_const", dest="compresslevel",
245+
const=2,
246+
help="use compression level 2 (default)")
247+
compress_group.add_argument(
248+
"-3", "--best", action="store_const", dest="compresslevel",
249+
const=_COMPRESS_LEVEL_BEST,
250+
help="use compression level 3 (best)")
251+
compress_group.add_argument(
252+
"-d", "--decompress", action="store_false",
253+
dest="compress",
254+
help="Decompress the file instead of compressing.")
241255
args = parser.parse_args()
242256

243-
if args.fast:
244-
compresslevel = _COMPRESS_LEVEL_FAST
245-
elif args.best:
246-
compresslevel = _COMPRESS_LEVEL_BEST
247-
else:
248-
compresslevel = _COMPRESS_LEVEL_TRADEOFF
257+
compresslevel = args.compresslevel or _COMPRESS_LEVEL_TRADEOFF
249258

250259
if args.compress:
251260
out_filename = args.file + ".gz"

0 commit comments

Comments
 (0)