You are here

function ip2country_drush_command in IP-based Determination of a Visitor's Country 7

Same name and namespace in other branches
  1. 8 ip2country.drush.inc \ip2country_drush_command()

Implements hook_drush_command().

File

./ip2country.drush.inc, line 18

Code

function ip2country_drush_command() {
  $items = array();
  $items['ip2country-update'] = array(
    'aliases' => array(
      'ip-update',
    ),
    'description' => dt('Updates the Ip2Country database from the selected Regional Internet Registry.'),
    'drupal dependencies' => array(
      'ip2country',
    ),
    'core' => array(
      '7',
    ),
    'options' => array(
      'registry' => dt('Registry used to obtain data.'),
    ),
    'examples' => array(
      'drush ip-update --registry=ripe' => dt('Updates Ip2Country database of ip/country associations.'),
    ),
  );
  $items['ip2country-lookup'] = array(
    'aliases' => array(
      'ip-lookup',
    ),
    'description' => dt('Returns the country name and two-character ISO 3166 country code associated with the given IP address.'),
    'drupal dependencies' => array(
      'ip2country',
    ),
    'core' => array(
      '7',
    ),
    'arguments' => array(
      'IPV4' => dt('The IPV4 address to look up, in dotted-quad notation (e.g. 127.0.0.1).'),
    ),
    'required-arguments' => TRUE,
    'examples' => array(
      '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. array('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' => array(
      'default' => 'table',
      'pipe-format' => 'list',
      'field-labels' => array(
        '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'] = array(
    'aliases' => array(
      'ip-status',
    ),
    'description' => dt('Displays the time and RIR of the last database update.'),
    'drupal dependencies' => array(
      'ip2country',
    ),
    'core' => array(
      '7',
    ),
    'examples' => array(
      'drush ip-status' => dt('Displays the time and RIR of the last database update.'),
    ),
  );
  return $items;
}