File tree Expand file tree Collapse file tree 7 files changed +99
-7
lines changed
Expand file tree Collapse file tree 7 files changed +99
-7
lines changed Original file line number Diff line number Diff line change 1- Feature : Default aliases
1+ Feature : Command aliases
22 In order to be more effective when using the shell
33 As a user
44 I want to be able to use the default command aliases
@@ -22,3 +22,14 @@ Feature: Default aliases
2222 | ls cms |
2323 | sl cms foobar |
2424 | cat cms |
25+
26+ Scenario : List aliases
27+ Given I execute the "shell:alias:list" command
28+ Then the command should not fail
29+ And I should see a table containing the following rows:
30+ | Alias | Command |
31+ | cd | shell :path :change {arg1 } |
32+ | ls | node :list {arg1 } |
33+
34+
35+
Original file line number Diff line number Diff line change 1+ Feature : Reload the configuration
2+ In order to reload the configuration
3+ As a user
4+ I want to be able to execute a command which does that
5+
6+ Scenario : Reload configuration
7+ Given I execute the "shell:config:reload" command
8+ Then the command should not fail
Original file line number Diff line number Diff line change @@ -215,7 +215,9 @@ private function registerCommands()
215215 $ this ->add (new CommandPhpcr \LockUnlockCommand ());
216216
217217 // add shell-specific commands
218+ $ this ->add (new CommandShell \AliasListCommand ());
218219 $ this ->add (new CommandShell \ConfigInitCommand ());
220+ $ this ->add (new CommandShell \ConfigReloadCommand ());
219221 $ this ->add (new CommandShell \PathChangeCommand ());
220222 $ this ->add (new CommandShell \PathShowCommand ());
221223 $ this ->add (new CommandShell \ExitCommand ());
Original file line number Diff line number Diff line change 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 AliasListCommand extends Command
10+ {
11+ public function configure ()
12+ {
13+ $ this ->setName ('shell:alias:list ' );
14+ $ this ->setDescription ('List all the registered aliases ' );
15+ $ this ->setHelp (<<<EOT
16+ EOT
17+ );
18+ }
19+
20+ public function execute (InputInterface $ input , OutputInterface $ output )
21+ {
22+ $ config = $ this ->getHelper ('config ' );
23+ $ aliases = $ config ->getConfig ('alias ' );
24+
25+ $ table = clone $ this ->getHelper ('table ' );
26+ $ table ->setHeaders (array ('Alias ' , 'Command ' ));
27+
28+ foreach ($ aliases as $ alias => $ command ) {
29+ $ table ->addRow (array ($ alias , $ command ));
30+ }
31+
32+ $ table ->render ($ output );
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PHPCR \Shell \Console \Command \Shell ;
4+
5+ use Symfony \Component \Filesystem \Filesystem ;
6+ use Symfony \Component \Console \Command \Command ;
7+ use Symfony \Component \Console \Input \InputInterface ;
8+ use Symfony \Component \Console \Output \OutputInterface ;
9+
10+ class ConfigReloadCommand extends Command
11+ {
12+ protected $ output ;
13+
14+ public function configure ()
15+ {
16+ $ this ->setName ('shell:config:reload ' );
17+ $ this ->setDescription ('Reload the configuration ' );
18+ $ this ->setHelp (<<<EOT
19+ Reload the configuration
20+ EOT
21+ );
22+ }
23+
24+ public function execute (InputInterface $ input , OutputInterface $ output )
25+ {
26+ $ this ->output = $ output ;
27+ $ config = $ this ->getHelper ('config ' );
28+ $ config ->loadConfig ();
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -73,7 +73,10 @@ public function getConfigDir()
7373 return $ home ;
7474 }
7575
76- private function loadConfig ()
76+ /**
77+ * Load the configuration
78+ */
79+ public function loadConfig ()
7780 {
7881 $ config = array ();
7982
@@ -88,6 +91,8 @@ private function loadConfig()
8891 }
8992 }
9093
94+ $ this ->cachedConfig = $ config ;
95+
9196 return $ config ;
9297 }
9398
@@ -99,11 +104,10 @@ private function loadConfig()
99104 public function getConfig ($ type )
100105 {
101106 if (null !== $ this ->cachedConfig ) {
102- return $ this ->cachedConfig [' alias ' ];
107+ return $ this ->cachedConfig [$ type ];
103108 }
104109
105- $ this ->cachedConfig = $ this ->loadConfig ();
106-
107- return $ this ->cachedConfig ['alias ' ];
110+ $ this ->loadConfig ();
111+ return $ this ->cachedConfig [$ type ];
108112 }
109113}
Original file line number Diff line number Diff line change 1+ # Shell shortcuts
2+ aliases : shell:alias:list
3+
14# MySQL commands
25use : workspace:use
36workspaces : workspace:list
47select : query:select
58
69# Filesystem commands
710cd : shell:path:change {arg1}
8- rm : node:delete {arg1}
11+ rm : node:remove {arg1}
912mv : node:move {arg1} {arg2}
1013pwd : shell:path:show
1114exit : shell:exit
You can’t perform that action at this time.
0 commit comments