diff --git a/.travis.yml b/.travis.yml index 14aab56..c518bbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_install: - git clone https://github.com/drush-ops/drush /home/travis/web/drush - cd /home/travis/web/drush && git checkout 8.x && composer install - sudo ln -s /home/travis/web/drush/drush /usr/local/bin/drush - - cp -a /home/travis/build/backdrop-contrib/drush /home/travis/web/drush/commands/backdrop + - cp -a /home/travis/build/backdrop-contrib/backdrop-drush-extension /home/travis/web/drush/commands/backdrop - mysql -e "drop database if exists backdrop" - mysql -e "create database backdrop" - cd /home/travis/web diff --git a/backdrop.drush.inc b/backdrop.drush.inc index 6f2653d..8075e17 100644 --- a/backdrop.drush.inc +++ b/backdrop.drush.inc @@ -196,3 +196,20 @@ function system_module_implements_alter(&$implementations, $hook) { $implementations = array_diff_key($implementations, array('system' => NULL)); } } + +/** + * Drush chalk lets you format output text for color, bold, etc. + * + * @param string $output + * The string of text you wish to format. + * @param string $color + * The color or format you wish to use ie. '32m' for green. + * + * @return string + * The formatted string. + */ +function drush_chalk(string $output, string $color) { + $output = "\033[$color$output\033[0m"; + + return $output; +} diff --git a/commands/pm/backdrop_pm_enable.drush.inc b/commands/pm/backdrop_pm_enable.drush.inc index 475c13d..2563df5 100644 --- a/commands/pm/backdrop_pm_enable.drush.inc +++ b/commands/pm/backdrop_pm_enable.drush.inc @@ -57,14 +57,16 @@ function backdrop_command_pm_enable() { } $projects_list = implode(', ', $projects); + $projects_list = drush_chalk($projects_list, '1m'); $proceed = drush_confirm( "The following projects will be enabled: $projects_list. Do you want to enable the projects?" ); if (!$proceed) { + $cancelled = drush_chalk('Cancelled', '33m'); drush_print_r( - dt("\n\t\e[033mCancelled\e[0m $projects_list not enabled.\n") + dt("\n\t$cancelled: $projects_list not enabled.\n") ); } else { @@ -100,7 +102,9 @@ function _enable_project($project, $module_list) { $project_exists = backdrop_command_pm_enable_validate($project, $module_list); // If the $project directory does not exist then gracefully fail. if (!$project_exists) { - drush_print_r("\n\t\e[031mError\e[0m $project does not exist in your Backdrop installation."); + $error = drush_chalk('Error', '31m'); + $project = drush_chalk($project, '1m'); + drush_print_r("\n\t$error $project does not exist in your Backdrop installation."); drush_print_r("\tTry downloading $project first with the command: drush dl $project\n"); return FALSE; } @@ -111,17 +115,23 @@ function _enable_project($project, $module_list) { $module = $query->execute()->fetchAssoc(); if ($module['status']) { + $failed = drush_chalk('Failed', '31m'); + $module_name = drush_chalk($module['name'], '1m'); drush_print_r( - "\n\t\e[31m Failed\e[0m to enable module " . $module['name'] . ": it is already enabled.\n" + "\n\t$failed to enable module $module_name: it is already enabled.\n" ); return FALSE; } if (module_enable(array($project), FALSE)) { - drush_print_r("\n\t\e[32mSuccess\e[0m: module $project enabled.\n"); + $success = drush_chalk('Sucess', '32m'); + $project = drush_chalk($project, '1m'); + drush_print_r("\n\t$success: module $project enabled.\n"); return TRUE; } - drush_print_r("\n\t\e[31mFailed\e[0m to enable module " . $project); + $failed = drush_chalk('Failed', '31m'); + $project = drush_chalk($project, '1m'); + drush_print_r("\n\t$failed: to enable module " . $project); return FALSE; }