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

index 3322552e58ca929725140ecfe57467fcadb49ac5..ba613b3f8e9be04e303d5351ff018ec660489c75 100644 (file)
@@ -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
index 984aac67f24014a7a1965f82bf9645aefda18c21..a296d6a676372ffd3b552bc5b0f08b1abda11d43 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -236,6 +236,8 @@ IDLE
 Documentation
 -------------
 
+- Issue #28513: Documented command-line interface of zipfile.
+
 - Issue #16484: Change the default PYTHONDOCS URL to "https:", and fix the
   resulting links to use lowercase.  Patch by Sean Rodman, test by Kaushik
   Nadikuditi.