88 * License: GNU/GPLv2
99 * @see LICENSE.txt
1010 *
11- * This file: CLI handler (last modified: 2022.03.24 ).
11+ * This file: CLI handler (last modified: 2022.08.23 ).
1212 */
1313
1414namespace phpMussel \CLI ;
@@ -104,10 +104,11 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
104104 }
105105
106106 /** Fetch the command. */
107- $ Command = strtolower ($ this ->Loader ->substrBeforeFirst ($ Clean , ' ' ) ?: $ Clean );
107+ $ CommandNatural = $ this ->Loader ->substrBeforeFirst ($ Clean , ' ' ) ?: $ Clean ;
108+ $ Command = strtolower ($ CommandNatural );
108109
109110 /** Exit CLI-mode. */
110- if ($ Command === ' quit ' || $ Command === ' q ' || $ Command === ' exit ' ) {
111+ if (preg_match ( ' ~^(?:(?:[Qq]|ԛ)(?:[Uu][Ii][Tt])?|[Ee][Xx][Ii][Tt])$~ ' , $ CommandNatural ) ) {
111112 break ;
112113 }
113114
@@ -183,7 +184,7 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
183184 }
184185
185186 /** Generate a CoEx signature using a string. */
186- elseif ($ Command === ' coex ' ) {
187+ elseif (preg_match ( ' ~^(?:(?:[Cc]|ϲ|с)(?:[Oo]|ο|о)(?:[Ee]|е)(?:[Xx]|х))$~ ' , $ CommandNatural ) ) {
187188 $ TargetData = substr ($ Clean , strlen ($ Command ) + 1 );
188189 echo sprintf (
189190 "\n\$sha256:%s; \$StringLength:%d;%s \n" ,
@@ -194,7 +195,7 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
194195 }
195196
196197 /** 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 ) ) {
198199 $ TargetData = substr ($ Clean , strlen ($ Command ) + 1 );
199200 echo "\n" . bin2hex ($ TargetData ) . "\n" ;
200201 }
@@ -218,14 +219,14 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
218219 }
219220
220221 /** Scan a file or directory. */
221- elseif ($ Command === ' scan ' || $ Command === ' s ' ) {
222+ elseif (preg_match ( ' ~^(?:[Ss][Cc][Aa][Nn]|[Ss]|ѕ)$~ ' , $ CommandNatural ) ) {
222223 $ TargetData = substr ($ Clean , strlen ($ Command ) + 1 );
223224 echo "\n" ;
224225 echo $ this ->Scanner ->scan ($ TargetData ) . "\n" ;
225226 }
226227
227228 /** Print the command list. */
228- elseif ($ Command === ' c ' ) {
229+ elseif (preg_match ( ' ~^(?:[Cc]|ϲ|с)$~ ' , $ CommandNatural ) ) {
229230 echo "\n" . $ this ->Loader ->L10N ->getString ('cli_commands ' );
230231 }
231232
0 commit comments