From ceb1b43b08ac56603e2a2a6698c4f2593d517efd Mon Sep 17 00:00:00 2001 From: dantleech Date: Fri, 19 Dec 2014 10:58:38 +0100 Subject: [PATCH] Workspace is first argument --- CHANGELOG.md | 10 ++++++++-- .../Shell/Console/Command/ShellCommand.php | 4 +++- .../Shell/DependencyInjection/Container.php | 17 ++++++++--------- .../ProfileFromSessionInputSubscriber.php | 15 ++++++++++++++- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9436ef2a..22b5df9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,17 @@ Changelog dev-master ---------- +### Bug fixes + +- [config] Do not override CLI options with profile options + +### Features + +- [cli] Specify workspace with first argument +- [global] Refactored to use DI container and various general improvements - [references] Show UUIDs when listing reference properties - [transport] Added transport layer for experimental Jackalope FS implementation -- [misc] Wildcard (single asterisk) support in paths - [node] Added wilcard support to applicable node commands, including "node:list", "node:remove" and "node:property:show" -- [global] Refactored to use DI container and various general improvements - [node:references] Shows the referencing node paths instead of the referrered-to node path(s) alpha-6 diff --git a/src/PHPCR/Shell/Console/Command/ShellCommand.php b/src/PHPCR/Shell/Console/Command/ShellCommand.php index f04c819d..37b268db 100644 --- a/src/PHPCR/Shell/Console/Command/ShellCommand.php +++ b/src/PHPCR/Shell/Console/Command/ShellCommand.php @@ -9,6 +9,7 @@ use PHPCR\Shell\Console\Application\ShellApplication; use PHPCR\Shell\Console\Application\Shell; use PHPCR\Shell\Console\Input\StringInput; +use Symfony\Component\Console\Input\InputArgument; /** * The shell command is the command used to configure the shell session @@ -51,7 +52,6 @@ public function configure() new InputOption('--transport', '-t', InputOption::VALUE_REQUIRED, 'Transport to use.'), new InputOption('--phpcr-username', '-pu', InputOption::VALUE_REQUIRED, 'PHPCR Username.', 'admin'), new InputOption('--phpcr-password', '-pp', InputOption::VALUE_OPTIONAL, 'PHPCR Password.', 'admin'), - new InputOption('--phpcr-workspace','-pw', InputOption::VALUE_OPTIONAL, 'PHPCR Workspace.', 'default'), new InputOption('--db-username', '-du', InputOption::VALUE_REQUIRED, 'Database Username.', 'root'), new InputOption('--db-name', '-dn', InputOption::VALUE_REQUIRED, 'Database Name.', 'phpcr'), new InputOption('--db-password', '-dp', InputOption::VALUE_OPTIONAL, 'Database Password.'), @@ -65,6 +65,8 @@ public function configure() new InputOption('--profile', '-p', InputOption::VALUE_OPTIONAL, 'Speicfy a profile name, use wit --transport to update or create'), new InputOption('--unsupported', null, InputOption::VALUE_NONE, 'Show all commands, including commands not supported by the repository'), new InputOption('--command', null, InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Run the given command'), + + new InputArgument('workspace', InputArgument::OPTIONAL, 'Workspace to start with', 'default'), )); } diff --git a/src/PHPCR/Shell/DependencyInjection/Container.php b/src/PHPCR/Shell/DependencyInjection/Container.php index 1a856d6d..64757c9d 100644 --- a/src/PHPCR/Shell/DependencyInjection/Container.php +++ b/src/PHPCR/Shell/DependencyInjection/Container.php @@ -96,6 +96,14 @@ public function registerPhpcr() public function registerEvent() { if ($this->mode === self::MODE_STANDALONE) { + $this->register( + 'event.subscriber.profile_loader', + 'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber' + ) + ->addArgument(new Reference('config.profile_loader')) + ->addArgument(new Reference('helper.question')) + ->addTag('event.subscriber'); + $this->register( 'event.subscriber.profile_from_session_input', 'PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber' @@ -109,21 +117,12 @@ public function registerEvent() ->addArgument(new Reference('helper.question')) ->addTag('event.subscriber'); - $this->register( - 'event.subscriber.profile_loader', - 'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber' - ) - ->addArgument(new Reference('config.profile_loader')) - ->addArgument(new Reference('helper.question')) - ->addTag('event.subscriber'); - $this->register( 'event.subscriber.config_init', 'PHPCR\Shell\Subscriber\ConfigInitSubscriber' ) ->addArgument(new Reference('config.manager')) ->addTag('event.subscriber'); - } $this->register( diff --git a/src/PHPCR/Shell/Subscriber/ProfileFromSessionInputSubscriber.php b/src/PHPCR/Shell/Subscriber/ProfileFromSessionInputSubscriber.php index fbcd8412..fb59b8e2 100644 --- a/src/PHPCR/Shell/Subscriber/ProfileFromSessionInputSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ProfileFromSessionInputSubscriber.php @@ -35,12 +35,15 @@ public function handleProfileInit(ProfileInitEvent $e) $phpcrOptions = array( 'phpcr-username' => 'username', 'phpcr-password' => 'password', - 'phpcr-workspace' => 'workspace', ); foreach ($transportOptions as $optionName => $configName) { $value = $input->getOption($optionName); + if (!$value) { + continue; + } + if (null !== $value) { // sanitize some input values switch ($optionName) { @@ -61,7 +64,17 @@ public function handleProfileInit(ProfileInitEvent $e) $profile->set('transport', $configName, (string) $value); } + $workspace = $input->getArgument('workspace'); + + if ($workspace) { + $profile->set('phpcr', 'workspace', $workspace); + } + foreach ($phpcrOptions as $optionName => $configName) { + if (!$input->getOption($optionName)) { + continue; + } + $profile->set('phpcr', $configName, $input->getOption($optionName)); } }