commands/fzip/fzip.cif
changeset 75 3c3961c1ae26
parent 61 e07366cad0b2
--- a/commands/fzip/fzip.cif	Wed Sep 15 00:45:50 2010 +0100
+++ b/commands/fzip/fzip.cif	Fri Sep 17 20:24:30 2010 +0100
@@ -20,9 +20,9 @@
 
 Generates compressed archives of files or extracts files from a compressed archive. Both 'zip' and 'gzip' file formats are support ('zip' is used by default).
 
-==argument filename archive optional
+==argument filename zipfile optional
 
-The zip archive to create or extract.
+The zip archive to create or extract. If the zipfile argument is not specified when creating a zip, the first C<file> argument's name is used with a .zip or .gz extension appended.
 
 ==option bool v verbose
 
@@ -30,11 +30,11 @@
 
 ==option bool u unzip
 
-Extract files from the specified archive.
+Extract files from the specified zipfile.
 
 ==option filename d directory
 
-The directory to extract files into. Must be used in conjunction with '--unzip'.
+The directory to extract files into. Must be used in conjunction with C<--unzip>. If not specified, the current working directory is used.
 
 ==option bool r recurse
 
@@ -42,7 +42,7 @@
 
 ==option filename f file multiple
 
-A file or directory to archive. Only applicable when creating a new archive. If a directory is specified then it and any files contained immediately within that directory are archived. Use --recurse to archive all sub-directories and files within the directory. 
+A file or directory to add to the zipfile. Only applicable when creating a new archive. If a directory is specified then it and any files contained immediately within that directory are archived. Use --recurse to archive all sub-directories and files within the directory. 
 
 ==option enum t compression-type
 
@@ -54,7 +54,37 @@
 
 GNU Zip format. Note, this format can only handle a single file.
 
+==option bool o overwrite
+
+By default fzip will exit with an error if a file it is creating already exists on disk. Use this flag to silently overwrite instead.
+
 ==copyright
 
 Copyright (c) 2008-2010 Accenture. All rights reserved.
 
+==smoke-test
+
+export TESTDATA "This is some test data for fzip"
+echo -n "$TESTDATA" > test.txt
+rm test.txt.zip $Silent &| echo -n ""
+
+# Test zip
+fzip --file test.txt
+exists test.txt.zip || $Error
+rm test.txt
+
+# Test unzip
+fzip --unzip test.txt.zip
+exists test.txt || $Error
+cat -b test.txt | export -s RESULT
+var RESULT == "$TESTDATA" || $Error
+
+# Test that we don't overwrite files unless --overwrite is specified
+fzip --file test.txt $Silent &| var ? == "-11" || $Error
+fzip --file test.txt --overwrite
+
+fzip --unzip test.txt.zip $Silent &| var ? == "-11" || $Error
+fzip --unzip test.txt.zip --overwrite
+
+rm test.txt
+rm test.txt.zip