1
1
<?php
2
2
3
3
/**
4
- *
5
4
6
- * @package Conso PHP Console Creator
5
+ *
7
6
* @version 1.0.0
7
+ *
8
8
* @license MIT
9
+ *
9
10
* @category CLI
11
+ *
10
12
* @copyright 2019 Lotfio Lakehal
11
13
*/
12
-
13
- $ conso ->command ('--version ' , function ($ inp , $ out , $ app ){
14
-
15
- $ out ->writeLn ("\n " . $ app ->getName () . " version " . $ app ->getVersion () . "\n" , "yellow " );
16
-
14
+ $ conso ->command ('--version ' , function ($ inp , $ out , $ app ) {
15
+ $ out ->writeLn ("\n " .$ app ->getName ().' version ' .$ app ->getVersion ()."\n" , 'yellow ' );
17
16
})->alias (['-v ' ]);
18
17
19
- $ conso ->command ('--help ' , function ($ inp , $ out , $ app ){
20
-
21
- $ out ->writeLn ("\nUsage: \n\n" , 'yellow ' );
22
- $ out ->writeLn (" command:subcommand [options] [-flags] \n\n" );
23
-
24
- $ out ->writeLn ("Special flags: \n\n" , 'yellow ' );
25
-
26
- $ flags = $ inp ->reservedFlags ();
27
- $ out ->writeLn (" " . $ flags [0 ] . " " , 'green ' );
28
- $ out ->writeLn (" " . $ flags [1 ] . " \n" , 'green ' );
29
- $ out ->writeLn (" " . $ flags [2 ] . " " , 'green ' );
30
- $ out ->writeLn (" " . $ flags [3 ] . " \n" , 'green ' );
31
- $ out ->writeLn (" " . $ flags [4 ] . " " , 'green ' );
32
- $ out ->writeLn (" " . $ flags [5 ] . " \n" , 'green ' );
33
- $ out ->writeLn (" " . $ flags [6 ] . " " , 'green ' );
34
- $ out ->writeLn (" " . $ flags [7 ] . " \n" , 'green ' );
35
- $ out ->writeLn (" " . $ flags [8 ] . " " , 'green ' );
36
- $ out ->writeLn ( $ flags [9 ] . " \n" , 'green ' );
37
- $ out ->writeLn (" " . $ flags [10 ] . " " , 'green ' );
38
- $ out ->writeLn (" " . $ flags [11 ] . " \n" , 'green ' );
39
-
40
- $ out ->writeLn ("\nHelp: \n\n" , 'yellow ' );
41
- $ out ->writeLn (" The help special flag displays help for a given command: \n\n" );
42
- $ out ->writeLn (" To display application version, please use the -v or --version special flags. \n" );
43
- $ out ->writeLn (" To display the list of available commands, please use the -c or --commands special flags. \n" );
44
- $ out ->writeLn (" To silent warning, please use the -q or --quiet special flags. \n" );
45
- $ out ->writeLn (" To disable ansi, please use the --no-ansi special flag. \n" );
46
-
18
+ $ conso ->command ('--help ' , function ($ inp , $ out , $ app ) {
19
+ $ out ->writeLn ("\nUsage: \n\n" , 'yellow ' );
20
+ $ out ->writeLn (" command:subcommand [options] [-flags] \n\n" );
21
+
22
+ $ out ->writeLn ("Special flags: \n\n" , 'yellow ' );
23
+
24
+ $ flags = $ inp ->reservedFlags ();
25
+ $ out ->writeLn (' ' .$ flags [0 ].' ' , 'green ' );
26
+ $ out ->writeLn (' ' .$ flags [1 ]." \n" , 'green ' );
27
+ $ out ->writeLn (' ' .$ flags [2 ].' ' , 'green ' );
28
+ $ out ->writeLn (' ' .$ flags [3 ]." \n" , 'green ' );
29
+ $ out ->writeLn (' ' .$ flags [4 ].' ' , 'green ' );
30
+ $ out ->writeLn (' ' .$ flags [5 ]." \n" , 'green ' );
31
+ $ out ->writeLn (' ' .$ flags [6 ].' ' , 'green ' );
32
+ $ out ->writeLn (' ' .$ flags [7 ]." \n" , 'green ' );
33
+ $ out ->writeLn (' ' .$ flags [8 ].' ' , 'green ' );
34
+ $ out ->writeLn ($ flags [9 ]." \n" , 'green ' );
35
+ $ out ->writeLn (' ' .$ flags [10 ].' ' , 'green ' );
36
+ $ out ->writeLn (' ' .$ flags [11 ]." \n" , 'green ' );
37
+
38
+ $ out ->writeLn ("\nHelp: \n\n" , 'yellow ' );
39
+ $ out ->writeLn (" The help special flag displays help for a given command: \n\n" );
40
+ $ out ->writeLn (" To display application version, please use the -v or --version special flags. \n" );
41
+ $ out ->writeLn (" To display the list of available commands, please use the -c or --commands special flags. \n" );
42
+ $ out ->writeLn (" To silent warning, please use the -q or --quiet special flags. \n" );
43
+ $ out ->writeLn (" To disable ansi, please use the --no-ansi special flag. \n" );
47
44
})->alias (['-h ' ]);
48
45
49
- $ conso ->command ('--commands ' , function ($ inp , $ out , $ app ){
46
+ $ conso ->command ('--commands ' , function ($ inp , $ out , $ app ) {
50
47
// remove special commands
51
- $ commands = array_filter ($ app ->getCommands (), function ($ elem ){
52
- if (strpos ($ elem ['name ' ], '-- ' ) === FALSE ) return $ elem ;
48
+ $ commands = array_filter ($ app ->getCommands (), function ($ elem ) {
49
+ if (strpos ($ elem ['name ' ], '-- ' ) === false ) {
50
+ return $ elem ;
51
+ }
53
52
});
54
53
55
- if (count ($ commands ) > 0 )
56
- {
54
+ if (count ($ commands ) > 0 ) {
57
55
$ out ->writeLn ("\nAvailable Commands: \n\n" , 'yellow ' );
58
56
59
- $ max = max (array_map (function ($ elem ){ return count ($ elem );}, $ commands ));
57
+ $ max = max (array_map (function ($ elem ) { return count ($ elem ); }, $ commands ));
60
58
61
- foreach ($ commands as $ command )
62
- {
63
- $ out ->writeLn (" " . $ command ['name ' ] . str_repeat (' ' , ($ max - strlen ($ command ['name ' ])) + 4 ), 'green ' );
64
- $ out ->writeLn ($ command ['description ' ] . "\n" );
59
+ foreach ($ commands as $ command ) {
60
+ $ out ->writeLn (' ' .$ command ['name ' ].str_repeat (' ' , ($ max - strlen ($ command ['name ' ])) + 4 ), 'green ' );
61
+ $ out ->writeLn ($ command ['description ' ]."\n" );
65
62
}
66
63
67
64
$ out ->writeLn ("\n" );
68
65
}
69
-
70
66
})->alias (['-c ' ]);
71
67
72
- $ conso ->command ('--no-ansi ' , function ($ inp , $ out , $ app ){
68
+ $ conso ->command ('--no-ansi ' , function ($ inp , $ out , $ app ) {
73
69
$ out ->disableAnsi (); // disable ansi
74
- $ cm = explode (DIRECTORY_SEPARATOR , getcwd ());
75
- $ cmd = ' php ' . $ cm [count ($ cm ) - 1 ];
70
+ $ cm = explode (DIRECTORY_SEPARATOR , getcwd ());
71
+ $ cmd = ' php ' . $ cm [count ($ cm ) - 1 ];
76
72
passthru ($ cmd );
77
73
});
78
74
79
- $ conso ->command ('command ' , 'Conso \\Commands \\Command ' );
75
+ $ conso ->command ('command ' , 'Conso \\Commands \\Command ' );
0 commit comments