Skip to content

Commit e840edd

Browse files
committed
Add option to not process existing workspace as error
1 parent 08fd6d8 commit e840edd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/PHPCR/Util/Console/Command/WorkspaceCreateCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPCR\RepositoryInterface;
66
use PHPCR\SessionInterface;
77
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputOption;
89
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
@@ -28,6 +29,12 @@ protected function configure()
2829
$this
2930
->setName('phpcr:workspace:create')
3031
->addArgument('name', InputArgument::REQUIRED, 'Name of the workspace to create')
32+
->addOption(
33+
'silent-on-exist',
34+
null,
35+
InputOption::VALUE_NONE,
36+
'If set, an existing workspace will return a success code'
37+
)
3138
->setDescription('Create a workspace in the configured repository')
3239
->setHelp(<<<EOT
3340
The <info>workspace:create</info> command creates a workspace with the specified name.
@@ -65,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6572
sprintf('<comment>This repository already has a workspace called "%s"</comment>', $workspaceName)
6673
);
6774

68-
return 2;
75+
return $input->getOption('silent-on-exist') ? 0 : 2;
6976
}
7077

7178
$workspace->createWorkspace($workspaceName);

0 commit comments

Comments
 (0)