Skip to content

Commit dbdbed5

Browse files
committed
Add python -m isal.igzip usage
1 parent 4b751c3 commit dbdbed5

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
# Add any Sphinx extension module names here, as strings. They can be
3232
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3333
# ones.
34-
extensions = ["sphinx.ext.autodoc"
35-
]
34+
extensions = ["sphinx.ext.autodoc", 'sphinxarg.ext']
3635

3736
# Add any paths that contain templates here, relative to this directory.
3837
templates_path = ['_templates']

docs/includes/isal.igzip_usage.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
==========================
2+
python -m isal.igzip usage
3+
==========================
4+
5+
.. argparse::
6+
:module: isal.igzip
7+
:func: _argument_parser
8+
:prog: python -m isal.igzip

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Differences with zlib and gzip modules
5757

5858
.. include:: includes/igzip.rst
5959

60+
.. include:: includes/isal.igzip_usage.rst
61+
6062
============
6163
Contributing
6264
============

requirements-docs.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
sphinx
22
setuptools
3-
sphinx-rtd-theme
3+
sphinx-rtd-theme
4+
sphinx-argparse

src/isal/igzip.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)