You are here

function rules_drush_command in Rules 8.3

Same name and namespace in other branches
  1. 7.2 rules.drush.inc \rules_drush_command()

Implements hook_drush_command().

File

./rules.drush.inc, line 13
Rules module integration with Drush 8 and earlier.

Code

function rules_drush_command() {
  $items = [];
  $items['rules-list'] = [
    'aliases' => [
      'rules',
    ],
    'description' => dt('Lists all the active and inactive rules for your site.'),
    'drupal dependencies' => [
      'rules',
    ],
    'core' => [
      '8+',
    ],
    'options' => [
      'type' => [
        'description' => dt('Restricts output to either "rule" or "component". Default is to list both.'),
        'example-value' => 'rule, component',
      ],
    ],
    'examples' => [
      'drush rules-list' => dt('Lists both Reaction Rules and Rules Components.'),
      'drush rules-list --type=component' => dt('Lists only Rules Components.'),
      'drush rules-list --fields=rule' => dt('Lists just the machine names.'),
      'drush rules-list --pipe' => dt('Outputs machine names in a format suitable for piping.'),
    ],
    'outputformat' => [
      'default' => 'table',
      'pipe-format' => 'list',
      'field-labels' => [
        'rule' => (string) dt('Rule'),
        'label' => (string) dt('Label'),
        'event' => (string) dt('Event'),
        'active' => (string) dt('Active'),
      ],
      'output-data-type' => 'format-table',
    ],
  ];
  $items['rules-enable'] = [
    'aliases' => [
      're',
    ],
    'description' => dt('Enables a rule on your site.'),
    'arguments' => [
      'rule' => dt('Reaction Rule name (machine id) to enable.'),
    ],
    'required-arguments' => TRUE,
    'drupal dependencies' => [
      'rules',
    ],
    'core' => [
      '8+',
    ],
    'examples' => [
      'drush rules-enable test_rule' => dt('Enables the rule with machine name "test_rule".'),
    ],
  ];
  $items['rules-disable'] = [
    'aliases' => [
      'rd',
    ],
    'description' => dt('Disables a rule on your site.'),
    'arguments' => [
      'rule' => dt('Reaction Rule name (machine id) to disable.'),
    ],
    'required-arguments' => TRUE,
    'drupal dependencies' => [
      'rules',
    ],
    'core' => [
      '8+',
    ],
    'examples' => [
      'drush rules-disable test_rule' => dt('Disables the rule with machine name "test_rule".'),
    ],
  ];
  $items['rules-delete'] = [
    'description' => dt('Deletes a rule on your site.'),
    'arguments' => [
      'rule' => dt('Rule name (machine id) to delete.'),
    ],
    'required-arguments' => TRUE,
    'drupal dependencies' => [
      'rules',
    ],
    'core' => [
      '8+',
    ],
    'examples' => [
      'drush rules-delete test_rule' => dt('Permanently deletes the rule with machine name "test_rule".'),
    ],
  ];
  $items['rules-export'] = [
    'description' => dt('Exports a Rule in YAML format.'),
    'arguments' => [
      'rule' => dt('Rule name (machine id) to export.'),
    ],
    'required-arguments' => TRUE,
    'examples' => [
      'drush rules-export test_rule > rules.reaction.test_rule.yml' => dt('Exports the Rule with machine name "test_rule" and saves it in a .yml file.'),
      'drush --pipe --type=component rules-list | xargs -I{}  sh -c "drush rules-export \'{}\' > \'rules.component.{}.yml\'"' => dt('Exports all Rules Components into individual YAML files.'),
    ],
    'drupal dependencies' => [
      'rules',
    ],
    'core' => [
      '8+',
    ],
  ];

  /*
   * @codingStandardsIgnoreStart
   *
   * @todo Not yet implemented.
   *
   * $items['rules-revert'] = [
   *   'description' => dt('Reverts a rule to its original state on your site.'),
   *   'arguments' => [
   *     'rule' => dt('Rule name (machine id) to revert.'),
   *   ],
   *   'required-arguments' => TRUE,
   *   'drupal dependencies' => ['rules'],
   *   'core' => ['8+'],
   *   'examples' => [
   *     'drush rules-revert test_rule' => dt('Restores a module-provided Rule to its original state. If the Rule hasn\'t been customized on the site, this has no effect.'),
   *   ],
   * ];
   * @codingStandardsIgnoreEnd
   */
  return $items;
}