Skip to content

Commit

Permalink
check if there are any commands before doing anything with the args
Browse files Browse the repository at this point in the history
  • Loading branch information
scribu committed Oct 2, 2011
1 parent 468d6a0 commit f6abf48
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions wp-cli.php
Expand Up @@ -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'];

Expand All @@ -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();
}
}

0 comments on commit f6abf48

Please sign in to comment.