Skip to content

Commit c117f1c

Browse files
committed
Added 'unsupported' option to list all commands
1 parent abdc97e commit c117f1c

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

features/bootstrap/FeatureContext.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function beforeScenario()
5252
$this->applicationTester->run(array(
5353
'--transport' => 'jackrabbit',
5454
'--no-interaction' => true,
55+
'--unsupported' => true, // test all the commands, even if they are unsupported (we test for the fail)
5556
), array(
5657
'interactive' => true,
5758
));

src/PHPCR/Shell/Console/Application/ShellApplication.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,17 @@ public function renderException($e, $output)
380380
$output->writeln(sprintf('<fg=red>%s</fg=red>', $e->getMessage()));
381381
} while ($e = $e->getPrevious());
382382
}
383+
384+
public function add(Command $command)
385+
{
386+
if ($command instanceof PhpcrShellCommand) {
387+
$showUnsupported = $this->sessionInput->getOption('unsupported');
388+
389+
if ($showUnsupported || $command->isSupported($this->getHelperSet()->get('repository'))) {
390+
return parent::add($command);
391+
}
392+
} else {
393+
parent::add($command);
394+
}
395+
}
383396
}

src/PHPCR/Shell/Console/Command/PhpcrShellCommand.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPCR\Shell\Console\Command;
44

55
use Symfony\Component\Console\Command\Command;
6+
use PHPCR\Shell\Console\Helper\RepositoryHelper;
67

78
class PhpcrShellCommand extends Command
89
{
@@ -19,17 +20,27 @@ public function dequiresDescriptor($descriptorKey, $value = null)
1920
$this->descriptorDequires[$descriptorKey] = $value;
2021
}
2122

22-
public function isEnabled()
23+
public function getDescriptorRequires()
24+
{
25+
return $this->descriptorRequires;
26+
}
27+
28+
public function getDescriptorDequires()
29+
{
30+
return $this->descriptorDequires;
31+
}
32+
33+
public function isSupported(RepositoryHelper $repositoryHelper)
2334
{
2435
foreach ($this->descriptorRequires as $key => $value) {
25-
$has = $this->getHelper('repository')->hasDescriptor($key, $value);
36+
$has = $repositoryHelper->hasDescriptor($key, $value);
2637
if (!$has) {
2738
return false;
2839
}
2940
}
3041

3142
foreach ($this->descriptorDequires as $key => $value) {
32-
$has = $this->getHelper('repository')->hasDescriptor($key, $value);
43+
$has = $repositoryHelper->hasDescriptor($key, $value);
3344

3445
if ($has) {
3546
return false;
@@ -38,4 +49,10 @@ public function isEnabled()
3849

3950
return true;
4051
}
52+
53+
public function getDescriptor()
54+
{
55+
56+
return true;
57+
}
4158
}

src/PHPCR/Shell/Console/Command/ShellCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function configure()
4242
new InputOption('--db-driver', '-dd', InputOption::VALUE_REQUIRED, 'Database Transport.', 'pdo_mysql'),
4343
new InputOption('--db-path', '-dP', InputOption::VALUE_REQUIRED, 'Database Path.'),
4444
new InputOption('--no-interaction', null, InputOption::VALUE_NONE, 'Turn off interaction (for testing purposes)'),
45+
new InputOption('--unsupported', null, InputOption::VALUE_NONE, 'Show all commands, including commands not supported by the repository'),
4546
new InputOption('--repo-url', '-url', InputOption::VALUE_REQUIRED, 'URL of repository (e.g. for jackrabbit).',
4647
'http://localhost:8080/server/'
4748
),

0 commit comments

Comments
 (0)