You are here

function drush_computing_create in Drupal Computing 7

File

./computing.drush.inc, line 113
Drupal Hybrid Computing drush interface. To use this, please install Drush at http://drupal.org/project/drush

Code

function drush_computing_create($app, $command, $description = NULL, $fields = NULL) {

  // read stuff from STDIN.
  if ($fields == '-') {
    $fields = stream_get_contents(STDIN);
  }
  if (drush_get_option('json', NULL) && !empty($fields)) {
    $fields_json = $fields;
    $fields = drush_json_decode($fields_json);
    if (!is_array($fields)) {
      drush_set_error('JSON_PARSE_ERROR', "Cannot parse fields json: {$fields_json}");
    }
  }
  else {
    if (!empty($fields)) {

      // attention: this might have escape characters issue.
      $pairs = explode('|', $fields);
      $fields = array();
      foreach ($pairs as $pair) {
        $key_value = explode('=', $pair);
        $fields[$key_value[0]] = $key_value[1];
      }
    }
    else {
      $fields = array();
    }
  }

  //var_dump($options);
  $id = computing_create_record($app, $command, $description, $fields);
  drush_print("Created command with ID: " . $id);
  drush_print_pipe($id);
}