helloworld.script 1.3 KB

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