From 24989d359b97748de49838da98efbcc98877e0e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 9 Nov 2012 23:12:20 +0100 Subject: [PATCH] Add ArgvParser --- .../install/files/lib/system/CLIWCF.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wcfsetup/install/files/lib/system/CLIWCF.class.php b/wcfsetup/install/files/lib/system/CLIWCF.class.php index 2b321de390..a5bc4b9ddb 100644 --- a/wcfsetup/install/files/lib/system/CLIWCF.class.php +++ b/wcfsetup/install/files/lib/system/CLIWCF.class.php @@ -9,6 +9,7 @@ use wcf\system\exception\IllegalLinkException; use wcf\system\exception\UserInputException; use wcf\system\user\authentication\UserAuthenticationFactory; use wcf\util\StringUtil; +use Zend\Console\Getopt as ArgvParser; use Zend\Loader\StandardAutoloader as ZendLoader; /** @@ -40,10 +41,28 @@ class CLIWCF extends WCF { $zendLoader = new ZendLoader(array(ZendLoader::AUTOREGISTER_ZF => true)); $zendLoader->register(); + $this->initArgv(); $this->initPHPLine(); $this->initAuth(); } + /** + * Initializes parsing of command line options. + */ + protected function initArgv() { + $opts = new ArgvParser(array( + 'v' => 'Verbose: Show more output', + 'q' => 'Quiet: Show less output', + 'h|help' => 'Show this help' + )); + $opts->setOptions(array(ArgvParser::CONFIG_CUMULATIVE_FLAGS => true)); + $opts->parse(); + if ($opts->getOption('help')) { + echo $opts->getUsageMessage(); + exit; + } + } + /** * Initializes PHPLine. */ -- 2.20.1