4 // This example demonstrates how to write a drush
5 // "shebang" script. These scripts start with the
6 // line "#!/usr/bin/env drush" or "#!/full/path/to/drush".
8 // See `drush topic docs-scripts` for more information.
10 drush_print("Hello world!");
12 drush_print("The arguments to this command were:");
15 // If called with --everything, use drush_get_arguments
16 // to print the commandline arguments. Note that this
17 // call will include 'php-script' (the drush command)
18 // and the path to this script.
20 if (drush_get_option('everything')) {
21 drush_print(" " . implode("\n ", drush_get_arguments()));
24 // If --everything is not included, then use
25 // drush_shift to pull off the arguments one at
26 // a time. drush_shift only returns the user
27 // commandline arguments, and does not include
28 // the drush command or the path to this script.
31 while ($arg = drush_shift()) {
32 drush_print(' ' . $arg);
39 // We can check which site was bootstrapped via
40 // the '@self' alias, which is defined only if
41 // there is a bootstrapped site.
43 $self_record = drush_sitealias_get_record('@self');
44 if (empty($self_record)) {
45 drush_print('No bootstrapped site.');
48 drush_print('The following site is bootstrapped:');
49 _drush_sitealias_print_record($self_record);