Skip to content

Commit e3dee4f

Browse files
committed
Added profile show command
1 parent 90f5329 commit e3dee4f

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Changelog
55
dev-master
66
----------
77

8+
### Features
9+
10+
- [profile:show] Added command to display current profile
11+
812
### Bug fixes
913

1014
- [embedded] No exit code returned
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: Show the profile
2+
In order to inspect the current profile
3+
As a user
4+
I need to be able to execute a command that does that
5+
6+
Scenario: Dump config
7+
Given I execute the "shell:profile:show --no-ansi --no-interaction" command
8+
Then the command should not fail
9+
And I should see the following:
10+
"""
11+
| name | jackrabbit |
12+
"""
13+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ protected function registerShellCommands()
189189
$this->add(new CommandShell\ConfigReloadCommand());
190190
$this->add(new CommandShell\PathChangeCommand());
191191
$this->add(new CommandShell\PathShowCommand());
192+
$this->add(new CommandShell\ProfileShowCommand());
192193
$this->add(new CommandShell\ExitCommand());
193194
}
194195

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PHPCR Shell package
5+
*
6+
* (c) Daniel Leech <daniel@dantleech.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PHPCR\Shell\Console\Command\Shell;
13+
14+
use PHPCR\Shell\Console\Command\BaseCommand;
15+
use Symfony\Component\Console\Input\InputInterface;
16+
use Symfony\Component\Console\Output\OutputInterface;
17+
18+
class ProfileShowCommand extends BaseCommand
19+
{
20+
protected $output;
21+
22+
public function configure()
23+
{
24+
$this->setName('shell:profile:show');
25+
$this->setDescription('Show the current profile configuration');
26+
$this->setHelp(<<<EOT
27+
Display the currently loaded profile configuration
28+
EOT
29+
);
30+
}
31+
32+
public function execute(InputInterface $input, OutputInterface $output)
33+
{
34+
$this->output = $output;
35+
$profile = $this->get('config.profile');
36+
37+
$output->writeln('<comment>NOTE: The profile may include information not relating to your current transport</comment>');
38+
$output->writeln('');
39+
foreach ($profile->toArray() as $domain => $config) {
40+
$output->writeln('<comment>' . $domain . '</comment>');
41+
$table = $this->get('helper.table')->create();
42+
$table->setHeaders(array('Key', 'Value'));
43+
44+
foreach ($config as $key => $value) {
45+
if ($key === 'db_password') {
46+
$value = '***';
47+
}
48+
49+
$table->addRow(array(
50+
$key,
51+
is_scalar($value) ? $value : json_encode($value)
52+
));
53+
}
54+
$table->render($output);
55+
}
56+
57+
}
58+
}

0 commit comments

Comments
 (0)