mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-25 17:23:00 +00:00
feature-cli: remove need for quotes when using php index.php exec ....
This commit is contained in:
parent
f72062332a
commit
5ba0fce2ff
1 changed files with 7 additions and 5 deletions
|
@ -81,7 +81,7 @@ function cli() {
|
||||||
|
|
||||||
case "exec":
|
case "exec":
|
||||||
file_put_contents("php://stderr", "Executing {$args[1]}\n");
|
file_put_contents("php://stderr", "Executing {$args[1]}\n");
|
||||||
exit(cli_exec($args[1]) ? 0 : 1);
|
exit(cli_exec(array_slice($args, 1)) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "help":
|
case "help":
|
||||||
|
@ -144,14 +144,16 @@ Be warned that you are effectively the superuser for your wiki right now, with c
|
||||||
* Executes a given Pepperminty Wiki shell command.
|
* Executes a given Pepperminty Wiki shell command.
|
||||||
* This function kill the process if the current execution environment is not the CLI.
|
* This function kill the process if the current execution environment is not the CLI.
|
||||||
* The returned exit code functions as a normal shell process exit code does.
|
* The returned exit code functions as a normal shell process exit code does.
|
||||||
* @param string $string The shell command to execute.
|
* @param string|array $string The shell command to execute.
|
||||||
* @return int The exit code of the command executed.
|
* @return int The exit code of the command executed.
|
||||||
*/
|
*/
|
||||||
function cli_exec(string $string) : int {
|
function cli_exec($string) : int {
|
||||||
global $settings, $cli_commands;
|
global $settings, $cli_commands;
|
||||||
ensure_cli();
|
ensure_cli();
|
||||||
|
|
||||||
$parts = preg_split("/\s+/", $string);
|
$parts = is_string($string) ? preg_split("/\s+/", $string) : $string;
|
||||||
|
if(!is_array($parts))
|
||||||
|
throw new Exception("Error: Invalid type. Expected an array of parts or a string to execute.");
|
||||||
|
|
||||||
if(!isset($cli_commands->{$parts[0]})) {
|
if(!isset($cli_commands->{$parts[0]})) {
|
||||||
echo("Error: The command with the name {$parts[0]} could not be found (try the help command instead).\n");
|
echo("Error: The command with the name {$parts[0]} could not be found (try the help command instead).\n");
|
||||||
|
|
Loading…
Reference in a new issue