Skip to content

Commit 9c0c4e0

Browse files
committed
Merge pull request #82 from phpcr/shell_clear
Added shell:clear command
2 parents 1d11269 + 230c0c7 commit 9c0c4e0

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dev-master
66

77
### Features
88

9+
- [shell] Added "shell:clear" command to support clearing the console output
910
- [general] The shell supports being embedded as a dependency
1011
- [node:edit] New command `node:edit` enables editing of entire node
1112

features/shell_clear.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: clear the screen
2+
In order to clear the screen
3+
As a user
4+
I want to be able to execute a command which does that.
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
9+
Scenario: Execute the shell clear command
10+
Given I execute the "shell:clear" command
11+
Then the command should not fail

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ protected function registerShellCommands()
227227
{
228228
// add shell-specific commands
229229
$this->add(new CommandShell\AliasListCommand());
230+
$this->add(new CommandShell\ClearCommand());
230231
$this->add(new CommandShell\ConfigInitCommand());
231232
$this->add(new CommandShell\ConfigReloadCommand());
232233
$this->add(new CommandShell\PathChangeCommand());
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace PHPCR\Shell\Console\Command\Shell;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
class ClearCommand extends Command
10+
{
11+
public function configure()
12+
{
13+
$this->setName('shell:clear');
14+
$this->setDescription('Clear the screen');
15+
$this->setHelp(<<<EOT
16+
Clear the screen
17+
EOT
18+
);
19+
}
20+
21+
public function execute(InputInterface $input, OutputInterface $output)
22+
{
23+
$output->write("\033[2J\033[;H");
24+
}
25+
}
26+

src/PHPCR/Shell/Resources/config.dist/alias.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
aliases: shell:alias:list
33
creload: shell:config:reload
44
cinit: shell:config:init
5+
clear: shell:clear
56

67
# MySQL commands
78
use: workspace:use {arg1}

0 commit comments

Comments
 (0)