function drush_save_config

8.0.x context.inc drush_save_config($context)
6.x context.inc drush_save_config($context)
7.x context.inc drush_save_config($context)
3.x context.inc drush_save_config($context)
4.x context.inc drush_save_config($context)
5.x context.inc drush_save_config($context)
master context.inc drush_save_config($context)

Save the settings in a specific context to the applicable configuration file This is useful is you want certain settings to be available automatically the next time a command is executed.

Parameters

$context: The context to save

File

includes/context.inc, line 534
The Drush context API implementation.

Code

function drush_save_config($context) {
  $filename = _drush_config_file($context);

  if ($filename) {
    $cache = drush_get_context($context);

    $fp = fopen($filename, "w+");
    if (!$fp) {
      return drush_set_error('DRUSH_PERM_ERROR', dt('Drushrc (!filename) could not be written', array('!filename' => $filename)));
    }
    else {
      fwrite($fp, "<?php\n");
      $timestamp = mktime();
      foreach ($cache as $key => $value) {
        $line = "\n\$options['$key'] = " . var_export($value, TRUE) . ';';
        fwrite($fp, $line);
      }
      fwrite($fp, "\n");
      fclose($fp);
      drush_log(dt('Drushrc file (!filename) was written successfully', array('!filename' => $filename)));
      return true;
    }

  }
  return false;
}