How to create a new drush command in Drupal 8.

I need to create a new drush command.
File name
mymodule.drush.inc
<?php

/**
 * @file Contains the code to generate the custom drush commands.
 */

/**
 * Implements hook_drush_command().
 */
function mymodule_drush_command() {
 
$items = array();
 
$items['say-hi'] = [
   
'description' => 'Say hi.',
   
'arguments' => [],
   
'aliases' => ['sh'],
  ];

  return
$items;
}

/**
 * Call back function.
 */
function drush_say_hi() {
 
drush_print('Hi');
}

?>
Tags