From f6abf48a7b422b84da8944762912833e1fce1b80 Mon Sep 17 00:00:00 2001 From: scribu Date: Sun, 2 Oct 2011 05:43:32 +0300 Subject: [PATCH] check if there are any commands before doing anything with the args --- wp-cli.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wp-cli.php b/wp-cli.php index 24e4e71e14..75955e333f 100755 --- a/wp-cli.php +++ b/wp-cli.php @@ -50,6 +50,14 @@ include $filename; } +// Check if there are commands installed +if(empty(WP_CLI::$commands)) { + WP_CLI::error('No commands installed'); + WP_CLI::line(); + WP_CLI::line('Visit the wp-cli page on github on more information on how to install commands.'); + exit(); +} + // Get the cli arguments $arguments = $GLOBALS['argv']; @@ -59,18 +67,11 @@ // Get the command $command = array_shift($arguments); -// Check if there are commands installed -if(empty(WP_CLI::$commands)) { - WP_CLI::error('No commands installed'); - WP_CLI::line(); - WP_CLI::line('Visit the wp-cli page on github on more information on how to install commands.'); - exit(); -} // Try to load the class, otherwise it's an Unknown command -elseif(isset(WP_CLI::$commands[$command])) { +if(isset(WP_CLI::$commands[$command])) { new WP_CLI::$commands[$command]($arguments); } // Show the general help for wp-cli else { WP_CLI::generalHelp(); -} \ No newline at end of file +}