function ip2country_drush_command in IP-based Determination of a Visitor's Country 8
Same name and namespace in other branches
- 7 ip2country.drush.inc \ip2country_drush_command()
Implements hook_drush_command().
File
- ./
ip2country.drush.inc, line 16 - ip2country module integration with Drush 8 and earlier.
Code
function ip2country_drush_command() {
$items = [];
$items['ip2country-update'] = [
'aliases' => [
'ip-update',
],
'description' => dt('Updates the Ip2Country database from the selected Regional Internet Registry.'),
'drupal dependencies' => [
'ip2country',
],
'core' => [
'8+',
],
'options' => [
'registry' => [
'description' => dt('Registry used to obtain data.'),
'example-value' => 'afrnic, apnic, arin, lapnic, or ripe',
],
'md5' => [
'description' => dt('Validate data integrity with MD5 checksum.'),
],
'batch_size' => [
'description' => dt('Row insertion batch size. Defaults to 200 rows per insert.'),
'example-value' => 200,
],
],
'examples' => [
'drush ip-update --registry=ripe' => dt('Updates Ip2Country database of ip/country associations.'),
'drush ip-update --registry=ripe --batch_size=200 --md5' => dt('Updates Ip2Country database of ip/country associations.'),
],
];
$items['ip2country-lookup'] = [
'aliases' => [
'ip-lookup',
],
'description' => dt('Returns the country name and two-character ISO 3166 country code associated with the given IP address.'),
'drupal dependencies' => [
'ip2country',
],
'core' => [
'8+',
],
'arguments' => [
'IPV4' => dt('The IPV4 address to look up, in dotted-quad notation (e.g. 127.0.0.1).'),
],
'required-arguments' => TRUE,
'examples' => [
'drush ip-lookup IPV4' => dt('Returns a country code associated with the given IP address.'),
'drush ip-lookup IPV4 --fields=ip_address,name --no-field-labels' => dt('Returns the IP address and Country name.'),
],
// Command returns a single keyed data item
// (e.g. ['country_code_iso_2' => 'UK']) that can either be printed with a
// label (e.g. 'Country: UK'), or output raw with --pipe (e.g. 'UK').
'outputformat' => [
'default' => 'table',
'pipe-format' => 'list',
'field-labels' => [
'ip_address' => (string) dt('IP address'),
'name' => (string) dt('Country'),
'country_code_iso2' => (string) dt('Country code'),
],
'output-data-type' => 'format-table',
],
];
$items['ip2country-status'] = [
'aliases' => [
'ip-status',
],
'description' => dt('Displays the time and RIR of the last database update.'),
'drupal dependencies' => [
'ip2country',
],
'core' => [
'8+',
],
'examples' => [
'drush ip-status' => dt('Displays the time and RIR of the last database update.'),
],
];
return $items;
}