pantheon-systems/terminus — pull request #15 by mikemilano (2013-08-29 00:58:31+00:00)
Title: Standardized site_uuid input for less repeating.

I went to add a new command and felt I was repeating too much code for the site_uuid to validate, offer prompt, optionally retrieve by site name, and validate again if prompt input was empty.

With each command, you can have control whether you want to offer a prompt, and whether you want to restrict input to striction a uuid.
```
function terminus_site_input($site_input, $prompt = TRUE, $uuid_only = FALSE) {
if (!$site_input && $prompt) {
$site_input = terminus_session_select_data('site_uuid');
}
if (terminus_validate_uuid($site_input)) {
return $site_input;
}
if (empty($site_input) || $uuid_only) {
return FALSE;
}
return terminus_get_site_uuid_by_name($site_input);
}
```

Usage to assign the $site_uuid with optional prompt, but only allow uuids (not site name)
```
if (!$site_uuid = terminus_site_input($site_uuid, TRUE, TRUE)) {
drush_log('You must supply a site UUID', 'failed');
return FALSE;
}
```

I updated all the functions that accept site_uuid to use this format, but I restricted to uuids only where they were not already testing for terminus_get_site_uuid_by_name(). If you want to allow site names for all, just remove the 2nd and 3rd arguments from where terminus_site_input() has them set.