summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-23 23:53:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-23 23:53:29 (GMT)
commitd27b455bbcedd232ad8490acff46f532a365be49 (patch)
treef81a8c6bf695aba1bf93e030a3a25b29a845f140 /Doc
parent44e2eaab5491881120aab43e2838da8afe7ab70e (diff)
downloadcpython-d27b455bbcedd232ad8490acff46f532a365be49.zip
cpython-d27b455bbcedd232ad8490acff46f532a365be49.tar.gz
cpython-d27b455bbcedd232ad8490acff46f532a365be49.tar.bz2
Issue #13477: Added command line interface to the tarfile module.
Original patch by Berker Peksag.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/tarfile.rst61
1 files changed, 61 insertions, 0 deletions
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
index b8b65b9..d7e3b5f 100644
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -591,6 +591,67 @@ A :class:`TarInfo` object also provides some convenient query methods:
Return :const:`True` if it is one of character device, block device or FIFO.
+.. _tarfile-commandline:
+
+Command Line Interface
+----------------------
+
+.. versionadded:: 3.4
+
+The :mod:`tarfile` module provides a simple command line interface to interact
+with tar archives.
+
+If you want to create a new tar archive, specify its name after the :option:`-c`
+option and then list the filename(s) that should be included::
+
+ $ python -m tarfile -c monty.tar spam.txt eggs.txt
+
+Passing a directory is also acceptable::
+
+ $ python -m tarfile -c monty.tar life-of-brian_1979/
+
+If you want to extract a tar archive into the current directory, use
+the :option:`-e` option::
+
+ $ python -m tarfile -e monty.tar
+
+You can also extract a tar archive into a different directory by passing the
+directory's name::
+
+ $ python -m tarfile -e monty.tar other-dir/
+
+For a list of the files in a tar archive, use the :option:`-l` option::
+
+ $ python -m tarfile -l monty.tar
+
+
+Command line options
+~~~~~~~~~~~~~~~~~~~~
+
+.. cmdoption:: -l <tarfile>
+ --list <tarfile>
+
+ List files in a tarfile.
+
+.. cmdoption:: -c <tarfile> <source1> <sourceN>
+ --create <tarfile> <source1> <sourceN>
+
+ Create tarfile from source files.
+
+.. cmdoption:: -e <tarfile> [<output_dir>]
+ --extract <tarfile> [<output_dir>]
+
+ Extract tarfile into the current directory if *output_dir* is not specified.
+
+.. cmdoption:: -t <tarfile>
+ --test <tarfile>
+
+ Test whether the tarfile is valid or not.
+
+.. cmdoption:: -v, --verbose
+
+ Verbose output
+
.. _tar-examples:
Examples