Browse files

make "phar-extract -l $file" not require the destination directory

  • Loading branch information...
1 parent e9163d9 commit d4bd73febbca7df9161faccfed2ce9122bc7495b @cweiske cweiske committed Aug 10, 2011
Showing with 12 additions and 3 deletions.
  1. +12 −3 phar-extract.php
View
15 phar-extract.php
@@ -40,19 +40,28 @@
$parser->addArgument('destination', array(
'action' => 'StoreString',
- 'description' => "Destination directory"
+ 'description' => "Destination directory",
+ 'optional' => true
));
// run the parser
try {
$result = $parser->parse();
+ $options = $result->options;
+ $args = $result->args;
+ if ($options['list'] !== true && !isset($args['destination'])) {
+ throw Console_CommandLine_Exception::factory(
+ 'ARGUMENT_REQUIRED',
+ array('argnum' => 2, 'plural' => 's'),
+ $parser,
+ $parser->messages
+ );
+ }
} catch (Exception $exc) {
$parser->displayError($exc->getMessage());
}
-$options = $result->options;
-$args = $result->args;
echo $parser->name . ' ' . $parser->version . PHP_EOL . PHP_EOL;

0 comments on commit d4bd73f

Please sign in to comment.