X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fcommands%2Fpm%2Fprojectinfo.pm.inc;fp=vendor%2Fdrush%2Fdrush%2Fcommands%2Fpm%2Fprojectinfo.pm.inc;h=bbb5e912404808c1a67225d9a286edcae352c19e;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drush/drush/commands/pm/projectinfo.pm.inc b/vendor/drush/drush/commands/pm/projectinfo.pm.inc new file mode 100644 index 000000000..bbb5e9124 --- /dev/null +++ b/vendor/drush/drush/commands/pm/projectinfo.pm.inc @@ -0,0 +1,87 @@ + $status))); + } + } +} + +/** + * Implementation of drush_hook_COMMAND(). + */ +function drush_pm_projectinfo() { + // Get specific requests. + $requests = pm_parse_arguments(func_get_args(), FALSE); + + // Get installed extensions and projects. + $extensions = drush_get_extensions(); + $projects = drush_get_projects($extensions); + + // If user did not specify any projects, return them all + if (empty($requests)) { + $result = $projects; + } + else { + $result = array(); + foreach ($requests as $name) { + if (array_key_exists($name, $projects)) { + $result[$name] = $projects[$name]; + } + else { + drush_log(dt('!project was not found.', array('!project' => $name)), LogLevel::WARNING); + continue; + } + } + } + + // Find the Drush commands that belong with each project. + foreach ($result as $name => $project) { + $drush_commands = pm_projectinfo_commands_in_project($project); + if (!empty($drush_commands)) { + $result[$name]['drush'] = $drush_commands; + } + } + + // If user specified --drush, remove projects with no drush extensions + if (drush_get_option('drush')) { + foreach ($result as $name => $project) { + if (!array_key_exists('drush', $project)) { + unset($result[$name]); + } + } + } + + // If user specified --status=1|0, remove projects with a distinct status. + if (($status = drush_get_option('status', FALSE)) !== FALSE) { + $status_code = ($status == 'enabled') ? 1 : 0; + foreach ($result as $name => $project) { + if ($project['status'] != $status_code) { + unset($result[$name]); + } + } + } + + return $result; +} + +function pm_projectinfo_commands_in_project($project) { + $drush_commands = array(); + if (array_key_exists('path', $project)) { + $commands = drush_get_commands(); + foreach ($commands as $commandname => $command) { + if (!array_key_exists("is_alias", $command) && ($command['path'] == $project['path'])) { + $drush_commands[] = $commandname; + } + } + } + return $drush_commands; +} +