Skip to content

Commit d8d9da0

Browse files
Issue #28513: Documented command-line interface of zipfile.
2 parents 93f26f7 + 92c1a90 commit d8d9da0

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

‎Doc/library/zipfile.rst‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,4 +632,60 @@ Instances have the following methods and attributes:
632632
Size of the uncompressed file.
633633

634634

635+
.. _zipfile-commandline:
636+
.. program:: zipfile
637+
638+
Command-Line Interface
639+
----------------------
640+
641+
The :mod:`zipfile` module provides a simple command-line interface to interact
642+
with ZIP archives.
643+
644+
If you want to create a new ZIP archive, specify its name after the :option:`-c`
645+
option and then list the filename(s) that should be included:
646+
647+
.. code-block:: shell-session
648+
649+
$ python -m zipfile -c monty.zip spam.txt eggs.txt
650+
651+
Passing a directory is also acceptable:
652+
653+
.. code-block:: shell-session
654+
655+
$ python -m zipfile -c monty.zip life-of-brian_1979/
656+
657+
If you want to extract a ZIP archive into the specified directory, use
658+
the :option:`-e` option:
659+
660+
.. code-block:: shell-session
661+
662+
$ python -m zipfile -e monty.zip target-dir/
663+
664+
For a list of the files in a ZIP archive, use the :option:`-l` option:
665+
666+
.. code-block:: shell-session
667+
668+
$ python -m zipfile -l monty.zip
669+
670+
671+
Command-line options
672+
~~~~~~~~~~~~~~~~~~~~
673+
674+
.. cmdoption:: -l <zipfile>
675+
676+
List files in a zipfile.
677+
678+
.. cmdoption:: -c <zipfile> <source1> ... <sourceN>
679+
680+
Create zipfile from source files.
681+
682+
.. cmdoption:: -e <zipfile> <output_dir>
683+
684+
Extract zipfile into target directory.
685+
686+
.. cmdoption:: -t <zipfile>
687+
688+
Test whether the zipfile is valid or not.
689+
690+
635691
.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

‎Misc/NEWS‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Core and Builtins
1616
Library
1717
-------
1818

19+
Documentation
20+
-------------
21+
22+
- Issue #28513: Documented command-line interface of zipfile.
23+
1924

2025
What's New in Python 3.6.0 beta 3
2126
=================================

0 commit comments

Comments
 (0)