function drush_performance_parse_args in Performance Logging and Monitoring 7.2
Same name and namespace in other branches
- 6.2 performance.drush.inc \drush_performance_parse_args()
- 6 performance.drush.inc \drush_performance_parse_args()
- 7 performance.drush.inc \drush_performance_parse_args()
Helper function to parse the arguments which are the same for both commands. Only columns differ.
2 calls to drush_performance_parse_args()
- drush_performance_details in ./
performance.drush.inc - drush_performance_summary in ./
performance.drush.inc - Summary page callback. Differs a little from the version in the module because drush_print_table() works differently.
File
- ./
performance.drush.inc, line 252 - Drush integration for the Performance module.
Code
function drush_performance_parse_args($args, $orderby, $columns) {
$arguments = array();
$default = TRUE;
// Set limit from arguments or fall back to default.
$arguments['limit'] = 25;
if ((count($args) > 2 || count($args) == 1) && isset($args[0])) {
if (is_numeric($args[0])) {
$arguments['limit'] = $args[0];
}
else {
return drush_set_error(dt('First argument must be numeric!'));
}
}
else {
// 1st parameter was most likely omitted, so we prepend the default to the
// arguments to make the following checks check the right argument :-)
array_unshift($args, $arguments['limit']);
}
// Order by column name.
$arguments['orderby'] = $orderby;
if (isset($args[1])) {
if (in_array($args[1], $columns)) {
$arguments['orderby'] = $args[1];
}
else {
return drush_set_error(dt('Unknown column name. Possible values are: !columns', array(
'!columns' => implode(', ', $columns),
)));
}
}
// Sort direction.
$arguments['direction'] = 'desc';
$options = array(
'asc',
'desc',
);
if (isset($args[2])) {
if (in_array($args[2], $options)) {
$arguments['direction'] = $args[2];
}
else {
return drush_set_error(dt('Unknown sort direction. Possible values are: !options', array(
'!options' => implode(', ', $options),
)));
}
}
return $arguments;
}