Helloworld.script

<?php

//
// This example demonstrates how to write a Drush
// script. These scripts are run with the php:script command. Use a double dash to
// send additional arguments: drush php:script foo.php -- apple --cider
//

use Drush\Drush;

$output->writeln("Hello world!");
$output->writeln("The extra options/arguments to this command were:");
$output->writeln(print_r($extra, true));

//
// We can check which site was bootstrapped via
// the '@self' alias, which is defined only if
// there is a bootstrapped site.
//
$self = Drush::aliasManager()->getSelf();
if (!$self->hasRoot()) {
  $output->writeln('No bootstrapped site.');
}
else {
  $output->writeln('The following site is bootstrapped:');
  $output->writeln(print_r($self->legacyRecord(), true));
}