Make extract the default command; further improve parameter help.

This commit is contained in:
Bastian Kleineidam 2010-03-06 11:29:25 +01:00
parent 26c455cb39
commit 702a80dbf0
3 changed files with 30 additions and 30 deletions

View File

@ -16,7 +16,7 @@
patool - simple manager for file archives of various types
.SH SYNOPSIS
\fBpatool\fP (\fBextract\fP|\fBlist\fP|\fBtest\fP) [\fIoptions\fP] <\fIarchive-file\fP>
\fBpatool\fP \fBcreate\fP [\fIoptions\fP] <\fIarchive-file\fP> [\fIfiles..\fP]
\fBpatool\fP \fBcreate\fP [\fIoptions\fP] <\fIarchive-file\fP> [\fIfiles\fP..]
\fBpatool\fP \fBformats\fP [\fIoptions\fP]
.SH DESCRIPTION
Various archive types can be created, extracted, tested and listed by
@ -35,7 +35,10 @@ It relies on helper applications to handle those archive formats
.SH COMMANDS
Several commands and options are available.
.SS \fBextract\fP
Extract files from an archive. Often one wants to extract all files
Extract files from an archive. This is the default command if no
command was given.
.br
Often one wants to extract all files
in an archive to a single subdirectory.
However, some archives contain multiple files in their root
directories. The patool program overcomes this problem by
@ -61,12 +64,12 @@ Verbose archive listing (if the helper application supports it).
Show help for this command.
.SS \fBcreate\fP
Create an archive from given files.
.TP
\fB--force\fP
Allow overwriting of local archives.
.TP
\fB\-\-verbose\fP
Verbose operation (if the helper application supports it).
.\" .TP
.\" \fB--force\fP
.\" Allow overwriting of local archives.
.\" .TP
.\" \fB\-\-verbose\fP
.\" Verbose operation (if the helper application supports it).
.TP
\fB\-\-help\fP
Show help for this command.

View File

@ -28,18 +28,20 @@ COMMANDS
Several commands and options are available.
extract
Extract files from an archive. Often one wants to extract all files in
an archive to a single subdirectory. However, some archives contain
multiple files in their root directories. The patool program overcomes
this problem by first extracting files to a unique (temporary) direc
tory, and then moving its contents back if possible. This also prevents
local files from being overwritten by mistake.
Extract files from an archive. This is the default command if no com
mand was given.
Often one wants to extract all files in an archive to a single subdi
rectory. However, some archives contain multiple files in their root
directories. The patool program overcomes this problem by first
extracting files to a unique (temporary) directory, and then moving its
contents back if possible. This also prevents local files from being
overwritten by mistake.
--force
Allow overwriting of local files.
--verbose
Be verbose when extracting (if the helper application supports
Be verbose when extracting (if the helper application supports
it).
--help Show help for this command.
@ -55,12 +57,6 @@ COMMANDS
create
Create an archive from given files.
--force
Allow overwriting of local archives.
--verbose
Verbose operation (if the helper application supports it).
--help Show help for this command.
test

19
patool
View File

@ -22,19 +22,18 @@ if not hasattr(sys, "version_info") or sys.version_info < (2, 4, 0, "final", 0):
raise SystemExit("This program requires Python 2.4 or later.")
from patoolib import handle_archive, list_formats, baker
# parameter help
params_force = {"force": "Overwrite files if they exist."}
params_verbose = {"verbose": "Print verbose output."}
params_verbose_force = dict(params_verbose.items() + params_force.items())
@baker.command(params=params_verbose_force)
@baker.command(default=True, params={
"force": "Allow overwriting of local files.",
"verbose": "Be verbose when extracting (if the helper application supports it)."
})
def extract (archive, verbose=False, force=False):
"""Extract files from archives."""
return handle_archive(archive, 'extract')
@baker.command(params=params_verbose)
@baker.command(params={
"verbose": "Verbose archive listing (if the helper application supports it).",
})
def list (archive, verbose=False):
"""List files in an archive."""
return handle_archive(archive, 'list')
@ -46,7 +45,9 @@ def create (archive, *args):
return handle_archive(archive, 'create', *args)
@baker.command(params=params_verbose)
@baker.command(params={
"verbose": "Verbose operation (if the helper application supports it).",
})
def test (archive, verbose=False):
"""Test files in an archive."""
return handle_archive(archive, 'test', verbose=verbose)