From 4c993840831628acbd074f294e1657bcfda54889 Mon Sep 17 00:00:00 2001 From: Sasa Bodiroza Date: Tue, 8 Jul 2008 23:38:59 +0200 Subject: Add function usage() to src/med-xpi-unpack to print out information on error, or -h/--help --- src/med-xpi-unpack | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/med-xpi-unpack b/src/med-xpi-unpack index 53b8bb1..9c66c89 100755 --- a/src/med-xpi-unpack +++ b/src/med-xpi-unpack @@ -24,23 +24,35 @@ XPIFILE=$1; OUTDIR=$2; +function usage() { + echo -e "med-xpi-unpack - Script to unpack XPI file to output directory.\n"; + echo "To run it call:"; + echo -e "$ med-xpi-unpack input_xpi_file output_directory\n"; + echo " input_xpi_file - packed XPI source tree"; + echo " output_directory - location where the unpacke XPI file is placed"; + exit 1; +} + +if [ $1 = "--help" -o $1 = "-h" ] ; then + usage; +fi; + if [ -z $XPIFILE ] ; then - echo "Missing xpiname directory."; - echo "Usage: med-xpi-unpack xpiname outdir"; - exit; + echo -e "Missing XPI file.\n"; + usage; fi; if [ -z $OUTDIR ] ; then - echo "Missing output directory."; - echo "Usage: med-xpi-unpack xpiname outdir"; - exit; + echo -e "Missing output directory.\n"; + usage; fi; if [ -d $OUTDIR ] ; then - echo "E: Output directory already exists."; - exit; + echo -e "E: Output directory already exists.\n"; + usage; fi; -if [ ! -e $XPIFILE ] ; then - echo "E: XPI file doesn't exist."; - exit; + +if [ ! -f $XPIFILE ] ; then + echo -e "E: XPI file doesn't exist.\n"; + usage; fi; mkdir $OUTDIR; -- cgit v1.2.3