From 7f38e480be30137284435ed1c3700ee327345a3a Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Sun, 25 Nov 2012 11:58:04 +0100 Subject: [PATCH] add -p cmd-opt --- ChangeLog | 12 +++++++++--- Qwad.pyw | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d24d3c0..44dd2c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,11 +4,12 @@ * only install qm-files for translation, not ts-files aswell * changed default directory to $HOME (so that file-selectors don't start at Qwads source or installation directory) -* add command line options: +* add command line options (NOTE: all paths must be absolute!): -h / --help = show help -v / --version = show Qwad version and exit -d / --download = download IOS (see examples below) -u / --unpack = unpack a wad file + -p / --pack = pack a folder as wad -g / --getversions = get available versions of given IOS -c / --convert = convert IOS name to hex (and vice versa) ====================================================================== @@ -21,10 +22,15 @@ >> Result: IOS58.wad **Unpack** - qwad -u - qwad -u IOS58.wad IOS58-Unpacked + qwad -u + qwad -u $PWD/IOS58.wad $PWD/IOS58-Unpacked >> Result: IOS58-Unpacked/ + **Pack** + qwad -p + qwad -p $PWD/IOS58-Unpacked/ $PWD/IOS58.wad + >> Result: IOS58.wad + **GetVersions** qwad -g qwad -g IOS9 diff --git a/Qwad.pyw b/Qwad.pyw index dd4cd61..1d8d78a 100644 --- a/Qwad.pyw +++ b/Qwad.pyw @@ -35,7 +35,8 @@ def opts(): help="IOS Version Output Decrypt Pack") parser.add_option('-u', "--unpack", dest="unpack", action="extend", type="string", metavar='Arguments', help="unpack a WAD") - + parser.add_option('-p', "--pack", dest="pack", action="extend", + type="string", metavar='Arguments', help="pack folder as WAD") parser.add_option('-g', "--getversions", dest="getversions", action="store_true", default=False, help="get available versions for IOS") parser.add_option('-c', "--convert", dest="convert", @@ -88,13 +89,25 @@ def opts(): else: os.mkdir(str(args[0]), 0755) if os.access(str(args[0]), os.W_OK): - folder = str(args[0]) - UnpackingCLI(wad, folder).start() + UnpackingCLI(wad, str(args[0])).start() sys.exit(0) else: print "Output folder %s not writeable." % str(args[0]) sys.exit(1) + if options.pack: + if os.access(str(options.pack[0]), os.R_OK): + folder = str(options.pack[0]) + else: + print "Input folder %s not readable." % str(options.pack[0]) + sys.exit(1) + if os.access(os.path.dirname(str(args[0])), os.W_OK): + PackingCLI(folder, str(args[0])).start() + sys.exit(0) + else: + print "Output file %s can't be created." % str(args[0]) + sys.exit(1) + def main(): # load our own translations translator = QTranslator()