Skip to content

Commit 1818f3a

Browse files
committed
Merge pull request #122 from phpcr/workspace_first
Workspace is first argument
2 parents 659b067 + ceb1b43 commit 1818f3a

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ Changelog
44
dev-master
55
----------
66

7+
### Bug fixes
8+
9+
- [config] Do not override CLI options with profile options
10+
11+
### Features
12+
13+
- [cli] Specify workspace with first argument
14+
- [global] Refactored to use DI container and various general improvements
715
- [references] Show UUIDs when listing reference properties
816
- [import/export] Renamed session import and export to `session:import` &
917
`session:export`
1018
- [config] Added user config for general settings
1119
- [config] Enable / disable showing execution times and set decimal expansion
1220
- [transport] Added transport layer for experimental Jackalope FS implementation
13-
- [misc] Wildcard (single asterisk) support in paths
1421
- [node] Added wilcard support to applicable node commands, including "node:list", "node:remove" and "node:property:show"
15-
- [global] Refactored to use DI container and various general improvements
1622
- [node:references] Shows the referencing node paths instead of the referrered-to node path(s)
1723

1824
alpha-6

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPCR\Shell\Console\Application\ShellApplication;
1010
use PHPCR\Shell\Console\Application\Shell;
1111
use PHPCR\Shell\Console\Input\StringInput;
12+
use Symfony\Component\Console\Input\InputArgument;
1213

1314
/**
1415
* The shell command is the command used to configure the shell session
@@ -51,7 +52,6 @@ public function configure()
5152
new InputOption('--transport', '-t', InputOption::VALUE_REQUIRED, 'Transport to use.'),
5253
new InputOption('--phpcr-username', '-pu', InputOption::VALUE_REQUIRED, 'PHPCR Username.', 'admin'),
5354
new InputOption('--phpcr-password', '-pp', InputOption::VALUE_OPTIONAL, 'PHPCR Password.', 'admin'),
54-
new InputOption('--phpcr-workspace','-pw', InputOption::VALUE_OPTIONAL, 'PHPCR Workspace.', 'default'),
5555
new InputOption('--db-username', '-du', InputOption::VALUE_REQUIRED, 'Database Username.', 'root'),
5656
new InputOption('--db-name', '-dn', InputOption::VALUE_REQUIRED, 'Database Name.', 'phpcr'),
5757
new InputOption('--db-password', '-dp', InputOption::VALUE_OPTIONAL, 'Database Password.'),
@@ -65,6 +65,8 @@ public function configure()
6565
new InputOption('--profile', '-p', InputOption::VALUE_OPTIONAL, 'Speicfy a profile name, use wit <info>--transport</info> to update or create'),
6666
new InputOption('--unsupported', null, InputOption::VALUE_NONE, 'Show all commands, including commands not supported by the repository'),
6767
new InputOption('--command', null, InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Run the given command'),
68+
69+
new InputArgument('workspace', InputArgument::OPTIONAL, 'Workspace to start with', 'default'),
6870
));
6971
}
7072

src/PHPCR/Shell/DependencyInjection/Container.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ public function registerPhpcr()
9595
public function registerEvent()
9696
{
9797
if ($this->mode === self::MODE_STANDALONE) {
98+
$this->register(
99+
'event.subscriber.profile_loader',
100+
'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber'
101+
)
102+
->addArgument(new Reference('config.profile_loader'))
103+
->addArgument(new Reference('helper.question'))
104+
->addTag('event.subscriber');
105+
98106
$this->register(
99107
'event.subscriber.profile_from_session_input',
100108
'PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber'
@@ -108,14 +116,6 @@ public function registerEvent()
108116
->addArgument(new Reference('helper.question'))
109117
->addTag('event.subscriber');
110118

111-
$this->register(
112-
'event.subscriber.profile_loader',
113-
'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber'
114-
)
115-
->addArgument(new Reference('config.profile_loader'))
116-
->addArgument(new Reference('helper.question'))
117-
->addTag('event.subscriber');
118-
119119
$this->register(
120120
'event.subscriber.config_init',
121121
'PHPCR\Shell\Subscriber\ConfigInitSubscriber'

src/PHPCR/Shell/Subscriber/ProfileFromSessionInputSubscriber.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ public function handleProfileInit(ProfileInitEvent $e)
3535
$phpcrOptions = array(
3636
'phpcr-username' => 'username',
3737
'phpcr-password' => 'password',
38-
'phpcr-workspace' => 'workspace',
3938
);
4039

4140
foreach ($transportOptions as $optionName => $configName) {
4241
$value = $input->getOption($optionName);
4342

43+
if (!$value) {
44+
continue;
45+
}
46+
4447
if (null !== $value) {
4548
// sanitize some input values
4649
switch ($optionName) {
@@ -61,7 +64,17 @@ public function handleProfileInit(ProfileInitEvent $e)
6164
$profile->set('transport', $configName, (string) $value);
6265
}
6366

67+
$workspace = $input->getArgument('workspace');
68+
69+
if ($workspace) {
70+
$profile->set('phpcr', 'workspace', $workspace);
71+
}
72+
6473
foreach ($phpcrOptions as $optionName => $configName) {
74+
if (!$input->getOption($optionName)) {
75+
continue;
76+
}
77+
6578
$profile->set('phpcr', $configName, $input->getOption($optionName));
6679
}
6780
}

0 commit comments

Comments
 (0)