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
2
2
In order to be more effective when using the shell
3
3
As a user
4
4
I want to be able to use the default command aliases
@@ -22,3 +22,14 @@ Feature: Default aliases
22
22
| ls cms |
23
23
| sl cms foobar |
24
24
| 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()
215
215
$ this ->add (new CommandPhpcr \LockUnlockCommand ());
216
216
217
217
// add shell-specific commands
218
+ $ this ->add (new CommandShell \AliasListCommand ());
218
219
$ this ->add (new CommandShell \ConfigInitCommand ());
220
+ $ this ->add (new CommandShell \ConfigReloadCommand ());
219
221
$ this ->add (new CommandShell \PathChangeCommand ());
220
222
$ this ->add (new CommandShell \PathShowCommand ());
221
223
$ 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()
73
73
return $ home ;
74
74
}
75
75
76
- private function loadConfig ()
76
+ /**
77
+ * Load the configuration
78
+ */
79
+ public function loadConfig ()
77
80
{
78
81
$ config = array ();
79
82
@@ -88,6 +91,8 @@ private function loadConfig()
88
91
}
89
92
}
90
93
94
+ $ this ->cachedConfig = $ config ;
95
+
91
96
return $ config ;
92
97
}
93
98
@@ -99,11 +104,10 @@ private function loadConfig()
99
104
public function getConfig ($ type )
100
105
{
101
106
if (null !== $ this ->cachedConfig ) {
102
- return $ this ->cachedConfig [' alias ' ];
107
+ return $ this ->cachedConfig [$ type ];
103
108
}
104
109
105
- $ this ->cachedConfig = $ this ->loadConfig ();
106
-
107
- return $ this ->cachedConfig ['alias ' ];
110
+ $ this ->loadConfig ();
111
+ return $ this ->cachedConfig [$ type ];
108
112
}
109
113
}
Original file line number Diff line number Diff line change
1
+ # Shell shortcuts
2
+ aliases : shell:alias:list
3
+
1
4
# MySQL commands
2
5
use : workspace:use
3
6
workspaces : workspace:list
4
7
select : query:select
5
8
6
9
# Filesystem commands
7
10
cd : shell:path:change {arg1}
8
- rm : node:delete {arg1}
11
+ rm : node:remove {arg1}
9
12
mv : node:move {arg1} {arg2}
10
13
pwd : shell:path:show
11
14
exit : shell:exit
You can’t perform that action at this time.
0 commit comments