]> granicus.if.org Git - python/commitdiff
Issue #28513: Documented command-line interface of zipfile.
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 2 Nov 2016 10:06:15 +0000 (12:06 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 2 Nov 2016 10:06:15 +0000 (12:06 +0200)
Doc/library/zipfile.rst
Misc/NEWS

index 1d6526ce95f0412e6dd6486a4e93b0f7ee32625e..bf482d265f304b0916ea14d4e72de140bfe14ce1 100644 (file)
@@ -574,4 +574,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
index 76ac3a69b5a0fc55a4e1967f9fbffbe83413313b..af4eb312af22b3fb516f83826e7dd33da5d65d00 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -471,6 +471,11 @@ C API
 - Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
   an iterable of integers. Now only strings and bytes-like objects are accepted.
 
+Documentation
+-------------
+
+- Issue #28513: Documented command-line interface of zipfile.
+
 Tests
 -----