annotate vendor/chi-teck/drupal-code-generator/templates/other/drush-command.twig @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author |
Chris Cannam |
date |
Thu, 28 Feb 2019 13:11:55 +0000 |
parents |
c75dbcec494b |
children |
|
rev |
line source |
Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * Contains {{ command_name }} drush command.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Implements hook_drush_help().
|
Chris@0
|
10 */
|
Chris@4
|
11 function {{ command_file_prefix|h2u }}_drush_help($section) {
|
Chris@0
|
12 switch ($section) {
|
Chris@0
|
13 case 'drush:{{ command_name }}':
|
Chris@0
|
14 $help = dt('Help text here.');
|
Chris@0
|
15 return $help;
|
Chris@0
|
16 }
|
Chris@0
|
17 }
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Implements hook_drush_command().
|
Chris@0
|
21 */
|
Chris@4
|
22 function {{ command_file_prefix|h2u }}_drush_command() {
|
Chris@0
|
23
|
Chris@0
|
24 $items['{{ command_name }}'] = [
|
Chris@0
|
25 'description' => '{{ description }}',
|
Chris@0
|
26 'arguments' => [
|
Chris@0
|
27 '{{ argument }}' => 'Argument description',
|
Chris@0
|
28 ],
|
Chris@0
|
29 'required-arguments' => TRUE,
|
Chris@0
|
30 'options' => [
|
Chris@0
|
31 '{{ option }}' => 'Option description',
|
Chris@0
|
32 ],
|
Chris@0
|
33 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
|
Chris@0
|
34 'aliases' => ['{{ alias }}'],
|
Chris@0
|
35 'examples' => [
|
Chris@0
|
36 'drush {{ alias }} {{ argument }} --{{ option }}' => 'It does something with this argument',
|
Chris@0
|
37 ],
|
Chris@0
|
38 ];
|
Chris@0
|
39
|
Chris@0
|
40 return $items;
|
Chris@0
|
41 }
|
Chris@0
|
42
|
Chris@0
|
43 /**
|
Chris@0
|
44 * Callback function for {{ command_name }} command.
|
Chris@0
|
45 */
|
Chris@4
|
46 function drush_{{ command_callback_suffix|h2u }}($argument) {
|
Chris@0
|
47
|
Chris@0
|
48 $option = drush_get_option('{{ option }}', 'default');
|
Chris@0
|
49 drush_print(dt('Argument value is "@argument".', ['@argument' => $argument]));
|
Chris@0
|
50 drush_print(dt('Option value is "@option".', ['@option' => $option]));
|
Chris@0
|
51
|
Chris@0
|
52 drush_set_error(dt('Error text here.'));
|
Chris@0
|
53 drush_log(dt('Log text here'));
|
Chris@0
|
54
|
Chris@0
|
55 }
|