summaryrefslogtreecommitdiff
path: root/Doc/library/zipfile.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-11-02 12:05:54 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-11-02 12:05:54 +0200
commitb858d7f07461ef342fcb0731e9d1353f7b64b7d2 (patch)
treedaf3c9b89173a9645d6279e911e390bbf4accc63 /Doc/library/zipfile.rst
parent333b6177a4b655a7ef6840a90f39b32569c140dd (diff)
downloadcpython-git-b858d7f07461ef342fcb0731e9d1353f7b64b7d2.tar.gz
Issue #28513: Documented command-line interface of zipfile.
Diffstat (limited to 'Doc/library/zipfile.rst')
-rw-r--r--Doc/library/zipfile.rst57
1 files changed, 57 insertions, 0 deletions
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index 3322552e58..ba613b3f8e 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -497,4 +497,61 @@ Instances have the following attributes:
Size of the uncompressed file.
+
+.. _zipfile-commandline:
+.. program:: zipfile
+
+Command-Line Interface
+----------------------
+
+The :mod:`zipfile` module provides a simple command-line interface to interact
+with ZIP archives.
+
+If you want to create a new ZIP archive, specify its name after the :option:`-c`
+option and then list the filename(s) that should be included:
+
+.. code-block:: shell-session
+
+ $ python -m zipfile -c monty.zip spam.txt eggs.txt
+
+Passing a directory is also acceptable:
+
+.. code-block:: shell-session
+
+ $ python -m zipfile -c monty.zip life-of-brian_1979/
+
+If you want to extract a ZIP archive into the specified directory, use
+the :option:`-e` option:
+
+.. code-block:: shell-session
+
+ $ python -m zipfile -e monty.zip target-dir/
+
+For a list of the files in a ZIP archive, use the :option:`-l` option:
+
+.. code-block:: shell-session
+
+ $ python -m zipfile -l monty.zip
+
+
+Command-line options
+~~~~~~~~~~~~~~~~~~~~
+
+.. cmdoption:: -l <zipfile>
+
+ List files in a zipfile.
+
+.. cmdoption:: -c <zipfile> <source1> ... <sourceN>
+
+ Create zipfile from source files.
+
+.. cmdoption:: -e <zipfile> <output_dir>
+
+ Extract zipfile into target directory.
+
+.. cmdoption:: -t <zipfile>
+
+ Test whether the zipfile is valid or not.
+
+
.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT