-
Notifications
You must be signed in to change notification settings - Fork 4
/
boilerplate.drush.inc
93 lines (82 loc) · 2.42 KB
/
boilerplate.drush.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* @file
* Drush integration for boilerplate custom module.
*
* Created by: Topsitemakers
* http://www.topsitemakers.com/
*/
/**
* Implements hook_drush_command().
*/
function boilerplate_drush_command() {
$items['boilerplate-hello'] = array(
'callback' => 'boilerplate_hello_command',
'description' => dt('Sample Drush command for boilerplate module.'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'arguments' => array(
'name' => dt('Optional. A name which will be greeted upon running the command.'),
),
'aliases' => array('boilerplate-hi'),
'topics' => array('docs-boilerplate'),
);
// Commandfiles may also add topics. These will appear in
// the list of topics when `drush topic` is executed.
$items['docs-boilerplate'] = array(
'description' => 'Info about boilerplate.',
'hidden' => TRUE,
'topic' => TRUE,
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'callback' => 'drush_print_file',
'callback arguments' => array(dirname(__FILE__) . '/CHANGELOG.md'),
);
return $items;
}
/**
* Implements hook_drush_help().
*/
function boilerplate_drush_help($section) {
switch ($section) {
case 'meta:boilerplate:title':
return dt("Boilerplate commands");
case 'meta:boilerplate:summary':
return dt("Interact with the Boilerplate module functionalities.");
case 'drush:boilerplate-hello':
return dt('Sample Drush command for boilerplate module. It will just greet you, optionally with a name you provided.');
}
}
/**
* Implements drush_hook_COMMAND_validate().
*/
function drush_boilerplate_hello_validate() {
$args = func_get_args();
if ($args[0] == 'me') {
$message = dt("You can't say hi to yourself");
return drush_set_error('NON_AVAILABLE', $message);
}
}
/**
* Callback for the boilerplate-hello command.
*/
function boilerplate_hello_command() {
$args = func_get_args();
$name = (!empty($args[0])) ? $args[0] : FALSE;
if ($name) {
drush_log(dt('Hello @name!', array('@name' => $name)), 'success');
}
else {
drush_log(dt('Hello there!'), 'success');
}
}
/**
* Command argument complete callback.
*
* Provides argument values for shell completion.
* To make this works you must execute the first time the command drush init
*
* @return array
* Array of popular fillings.
*/
function boilerplate_boilerplate_hello_complete() {
return array('values' => array('everybody', 'friends', 'Ali', 'Amelie'));
}