Skip to content

Commit 2e6930c

Browse files
committed
Autocomplete, fixed segfault, include properties
1 parent 3f44039 commit 2e6930c

File tree

3 files changed

+14
-61
lines changed

3 files changed

+14
-61
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
- New command: `file:import`: - import files into the repository.
66
- `node:list`: Added `--level` option to rescursively show children nodes and properties
7+
- Autocomplete completes property names in addition to node names in current path
78

89
## Improvements
910

1011
- `session:export:view`: Added `--pretty` option to `session:export:view` command to output formatted XML.
1112
- `session:export:view`: Ask confirmation before overwriting file.
1213

13-
## Bug Fixes
14+
## Bugs
1415

1516
- Aliases: Allow quoted arguments
17+
- Fixed autocomplete segfault

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,33 +103,9 @@ private function autocompleter($text)
103103
{
104104
$info = readline_info();
105105
$text = substr($info['line_buffer'], 0, $info['end']);
106-
107106
$list = $this->application->getHelperSet()->get('phpcr')->getSession()->autocomplete($text);
108107

109108
return $list;
110-
111-
if ($info['point'] !== $info['end']) {
112-
return false;
113-
}
114-
115-
// task name?
116-
if (false === strpos($text, ' ') || !$text) {
117-
return array_keys($this->application->all());
118-
}
119-
120-
// options and arguments?
121-
try {
122-
$command = $this->application->find(substr($text, 0, strpos($text, ' ')));
123-
} catch (\Exception $e) {
124-
return false;
125-
}
126-
127-
$list = array('--help');
128-
foreach ($command->getDefinition()->getOptions() as $option) {
129-
$list[] = '--' . $option->getName();
130-
}
131-
132-
return $list;
133109
}
134110

135111
/**

src/PHPCR/Shell/PhpcrSession.php

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,18 @@ public function setCwd($cwd)
4848
*/
4949
public function autocomplete($text)
5050
{
51-
// get last string
52-
if (!preg_match('&^(.+) &', $text, $matches)) {
53-
return false;
54-
}
55-
56-
$path = $matches[1];
57-
58-
if (substr($path, 0, 1) == '/') {
59-
$parentPath = PathHelper::getParentPath($path);
60-
try {
61-
$node = $this->getNode($parentPath);
62-
$list = array();
63-
foreach ($node->getNodes() as $path => $node) {
64-
$list[] = substr($parentPath, 1) . '/' . $path;
65-
}
66-
67-
return $list;
68-
} catch (PathNotFoundException $e) {
69-
return false;
70-
}
71-
} else {
72-
$cwd = $this->getCwd();
73-
try {
74-
$node = $this->getNode($cwd);
75-
$list = array();
76-
foreach ($node->getNodes() as $path => $node) {
77-
if ($this->getCwd() == '/') {
78-
$list[] = $path;
79-
} else {
80-
$list[] = $path;
81-
}
82-
}
83-
84-
return $list;
85-
} catch (PathNotFoundException $e) {
86-
return false;
51+
// return autocompletions for current path
52+
$cwd = $this->getCwd();
53+
try {
54+
$node = $this->getNode($cwd);
55+
$list = (array) $node->getNodeNames();
56+
foreach ($node->getProperties() as $name => $v) {
57+
$list[] = $name;
8758
}
59+
60+
return $list;
61+
} catch (PathNotFoundException $e) {
62+
return false;
8863
}
8964
}
9065

0 commit comments

Comments
 (0)