Skip to content

Commit 9d99b56

Browse files
committed
Added filter to node list
1 parent 8268072 commit 9d99b56

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

features/namespace_unregister.feature

Whitespace-only changes.

features/node_type_list.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ Feature: List registered node types
1212
And I should see a table containing the following rows:
1313
| Name | Primary Item Name | Abstract? | Mixin? | Queryable? |
1414
| nt:folder | no | no | yes | yes |
15+
16+
Scenario: List node types with filter
17+
Given I execute the "node-type:list mix.*" command
18+
Then the command should not fail
19+
And I should see a table containing the following rows:
20+
| Name | Primary Item Name | Abstract? | Mixin? | Queryable? |
21+
| mix:created | | no | yes | yes |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
303303
throw new \Exception('Not implemented: ' . $e->getMessage());
304304
}
305305

306-
$output->writeln('<error>' . $e->getMessage() . '</error>');
306+
$output->writeln('<error>(' . get_class($e) .') ' . $e->getMessage() . '</error>');
307307
return 1;
308308
}
309309

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ protected function configure()
1515
{
1616
$this->setName('node-type:list');
1717
$this->setDescription('List registered node types');
18+
$this->addArgument('filter', InputArgument::OPTIONAL, 'Perl regexp pattern');
1819
$this->setHelp(<<<HERE
1920
List all node types (both primary and mixins)
2021
HERE
@@ -27,13 +28,18 @@ public function execute(InputInterface $input, OutputInterface $output)
2728
$workspace = $session->getWorkspace();
2829
$namespaceRegistry = $workspace->getNamespaceRegistry();
2930
$nodeTypeManager = $workspace->getNodeTypeManager();
31+
$filter = $input->getArgument('filter');
3032

3133
$nodeTypes = $nodeTypeManager->getAllNodeTypes();
3234

3335
$table = clone $this->getHelper('table');
3436
$table->setHeaders(array('Name', 'Primary Item Name', 'Abstract?', 'Mixin?', 'Queryable?'));
3537

3638
foreach ($nodeTypes as $nodeType) {
39+
if ($filter && !preg_match('{' . $filter . '}', $nodeType->getName())) {
40+
continue;
41+
}
42+
3743
$table->addRow(array(
3844
$nodeType->getName(),
3945
$nodeType->getPrimaryItemName(),

0 commit comments

Comments
 (0)