From 910300fd24fc9e33f1412ddc6981988c4c532850 Mon Sep 17 00:00:00 2001 From: dantleech Date: Mon, 9 Jun 2014 10:43:08 +0200 Subject: [PATCH] Node list show templates - Behat tests - Now must be enabled explicitly --- CHANGELOG.md | 25 +++++++----- features/phpcr_node_list.feature | 19 +++++++++ features/shell_autocomplete.feature | 5 +++ .../Console/Command/Phpcr/NodeListCommand.php | 39 +++++++++++-------- 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 features/shell_autocomplete.feature diff --git a/CHANGELOG.md b/CHANGELOG.md index 483e1fc3..b245f147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,22 @@ -# alpha2 / dev-master +Changelog +========= -## Features +alpha-3 +------- -- New command: `file:import`: - import files into the repository. -- `node:list`: Added `--level` option to rescursively show children nodes and properties -- Autocomplete completes property names in addition to node names in current path +### Features -## Improvements +- [file]: `file:import` - New command to import files into the repository. +- [node]: `node:list` Added `--level` option to rescursively show children nodes and properties. +- [node]: `node:list` Show "unulfilled" property and child node definitions when listing node contents. -- `session:export:view`: Added `--pretty` option to `session:export:view` command to output formatted XML. +### Improvements + +- [export]: `session:export:view`: Added `--pretty` option to `session:export:view` command to output formatted XML. - `session:export:view`: Ask confirmation before overwriting file. +- [shell]: Autocomplete completes property names in addition to node names in current path. -## Bugs +### Bugs -- Aliases: Allow quoted arguments -- Fixed autocomplete segfault +- [shell]: *Aliases*: Allow quoted arguments. +- [shell]: Fixed autocomplete segfault. diff --git a/features/phpcr_node_list.feature b/features/phpcr_node_list.feature index dc737c2e..30979e49 100644 --- a/features/phpcr_node_list.feature +++ b/features/phpcr_node_list.feature @@ -41,3 +41,22 @@ Feature: List properites and chidren of current node | numberPropertyNode/ | nt:file | | | NumberPropertyNodeToCompare1/ | nt:file | | | NumberPropertyNodeToCompare2/ | nt:file | | + + + Scenario: List node hierarchy + Given the current node is "/" + And I execute the "node:list --level=1" command + Then the command should not fail + And I should see the following: + """ + daniel + """ + + Scenario: Show templates + Given the current node is "/tests_general_base" + And I execute the "node:list --template" command + Then the command should not fail + And I should see the following: + """ + | @* | nt:base | | + """ diff --git a/features/shell_autocomplete.feature b/features/shell_autocomplete.feature new file mode 100644 index 00000000..1b841fb1 --- /dev/null +++ b/features/shell_autocomplete.feature @@ -0,0 +1,5 @@ +Feature: Path autocompletion + In order to navigate the tree structure precisely and quickly + As a user logged into the shell + I need to be able to be able to invoke auto-completion + diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php index f39fda0c..179dee6b 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php @@ -25,14 +25,14 @@ protected function configure() $this->addOption('properties', null, InputOption::VALUE_NONE, 'List only the properties of this node'); $this->addOption('filter', 'f', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Optional filter to apply'); $this->addOption('level', 'L', InputOption::VALUE_REQUIRED, 'Depth of tree to show'); - $this->addOption('no-template', 'T', InputOption::VALUE_REQUIRED, 'Do not show template nodes and properties'); + $this->addOption('template', 't', InputOption::VALUE_NONE, 'Show template nodes and properties'); $this->setHelp(<<--level option. -The node:list command also shows template nodes and properties as defined a nodes node-type. -These can be suppressed using the --no-template option. +The node:list command can also shows template nodes and properties as defined a nodes node-type by +using the --template option. Template nodes and properties are prefixed with the "@" symbol. HERE ); } @@ -46,6 +46,7 @@ public function execute(InputInterface $input, OutputInterface $output) $this->showChildren = $input->getOption('children'); $this->showProperties = $input->getOption('properties'); + $this->showTemplate = $input->getOption('template'); $session = $this->getHelper('phpcr')->getSession(); @@ -113,14 +114,16 @@ private function renderChildren($currentNode, $table, $spacers) } } - // render empty schematic children - foreach ($childNodeNames as $childNodeName => $childNodeDefinition) { - // @todo: Determine and show cardinality, 1..*, *..*, 0..1, etc. - $table->addRow(array( - '' . implode('', $spacers) . '@' . $childNodeName . '', - implode('|', $childNodeDefinition->getRequiredPrimaryTypeNames()), - '', - )); + if ($this->showTemplate) { + // render empty schematic children + foreach ($childNodeNames as $childNodeName => $childNodeDefinition) { + // @todo: Determine and show cardinality, 1..*, *..*, 0..1, etc. + $table->addRow(array( + '' . implode('', $spacers) . '@' . $childNodeName . '', + implode('|', $childNodeDefinition->getRequiredPrimaryTypeNames()), + '', + )); + } } } @@ -150,12 +153,14 @@ private function renderProperties($currentNode, $table, $spacers) )); } - foreach ($propertyNames as $propertyName => $property) { - $table->addRow(array( - '' . implode('', $spacers). '@' . $propertyName . '', - '' . strtoupper(PropertyType::nameFromValue($property->getRequiredType())) . '', - '' - )); + if ($this->showTemplate) { + foreach ($propertyNames as $propertyName => $property) { + $table->addRow(array( + '' . implode('', $spacers). '@' . $propertyName . '', + '' . strtoupper(PropertyType::nameFromValue($property->getRequiredType())) . '', + '' + )); + } } } }