8
8
* License: GNU/GPLv2
9
9
* @see LICENSE.txt
10
10
*
11
- * This file: CLI handler (last modified: 2022.03.24 ).
11
+ * This file: CLI handler (last modified: 2022.08.23 ).
12
12
*/
13
13
14
14
namespace phpMussel \CLI ;
@@ -104,10 +104,11 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
104
104
}
105
105
106
106
/** Fetch the command. */
107
- $ Command = strtolower ($ this ->Loader ->substrBeforeFirst ($ Clean , ' ' ) ?: $ Clean );
107
+ $ CommandNatural = $ this ->Loader ->substrBeforeFirst ($ Clean , ' ' ) ?: $ Clean ;
108
+ $ Command = strtolower ($ CommandNatural );
108
109
109
110
/** Exit CLI-mode. */
110
- if ($ Command === ' quit ' || $ Command === ' q ' || $ Command === ' exit ' ) {
111
+ if (preg_match ( ' ~^(?:(?:[Qq]|ԛ)(?:[Uu][Ii][Tt])?|[Ee][Xx][Ii][Tt])$~ ' , $ CommandNatural ) ) {
111
112
break ;
112
113
}
113
114
@@ -183,7 +184,7 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
183
184
}
184
185
185
186
/** Generate a CoEx signature using a string. */
186
- elseif ($ Command === ' coex ' ) {
187
+ elseif (preg_match ( ' ~^(?:(?:[Cc]|ϲ|с)(?:[Oo]|ο|о)(?:[Ee]|е)(?:[Xx]|х))$~ ' , $ CommandNatural ) ) {
187
188
$ TargetData = substr ($ Clean , strlen ($ Command ) + 1 );
188
189
echo sprintf (
189
190
"\n\$sha256:%s; \$StringLength:%d;%s \n" ,
@@ -194,7 +195,7 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
194
195
}
195
196
196
197
/** Convert a binary string to a hexadecimal. */
197
- elseif ($ Command === ' hex_encode ' || $ Command === ' x ' ) {
198
+ elseif (preg_match ( ' ~^(?:[Hh][Ee][Xx]_[Ee][Nn][Cc][Oo][Dd][Ee]|[Xx]|х)$~ ' , $ CommandNatural ) ) {
198
199
$ TargetData = substr ($ Clean , strlen ($ Command ) + 1 );
199
200
echo "\n" . bin2hex ($ TargetData ) . "\n" ;
200
201
}
@@ -218,14 +219,14 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
218
219
}
219
220
220
221
/** Scan a file or directory. */
221
- elseif ($ Command === ' scan ' || $ Command === ' s ' ) {
222
+ elseif (preg_match ( ' ~^(?:[Ss][Cc][Aa][Nn]|[Ss]|ѕ)$~ ' , $ CommandNatural ) ) {
222
223
$ TargetData = substr ($ Clean , strlen ($ Command ) + 1 );
223
224
echo "\n" ;
224
225
echo $ this ->Scanner ->scan ($ TargetData ) . "\n" ;
225
226
}
226
227
227
228
/** Print the command list. */
228
- elseif ($ Command === ' c ' ) {
229
+ elseif (preg_match ( ' ~^(?:[Cc]|ϲ|с)$~ ' , $ CommandNatural ) ) {
229
230
echo "\n" . $ this ->Loader ->L10N ->getString ('cli_commands ' );
230
231
}
231
232
0 commit comments