Created
August 8, 2023 22:56
-
-
Save jessarcher/c4b9d8f5237d6158ec88d961986ebc6b to your computer and use it in GitHub Desktop.
The `artisan thankyou` command from my Laracon US 2023 talk.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
class ThankYouCommand extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = 'thankyou'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Command description'; | |
/** | |
* Execute the console command. | |
*/ | |
public function handle() | |
{ | |
$this | |
->echoSomethingCool() | |
->up(7) | |
->right(13) | |
->sleep(0.5) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->sleep(0.1) | |
->up() | |
->sleep(0.1) | |
->up() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->left(3) | |
->sleep(0.1) | |
->left(3) | |
->sleep(0.1) | |
->left(3) | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->left(3) | |
->eat() | |
->sleep(0.1) | |
->left(3) | |
->eat() | |
->sleep(0.1) | |
->left(3) | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->sleep(0.1) | |
->down() | |
->sleep(0.1) | |
->right(3) | |
->sleep(0.1) | |
->right(3) | |
->sleep(0.1) | |
->right(3) | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->up() | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->right(3) | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->eat() | |
->sleep(0.1) | |
->down() | |
->hideCursor() | |
->grin() | |
->sleep(2) | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->up() | |
->clearLine() | |
->sleep(0.2) | |
->finale() | |
->pause() | |
->showCursor(); | |
} | |
/** | |
* Move the cursor up. | |
*/ | |
protected function up($lines = 1) | |
{ | |
echo "\e[{$lines}A"; | |
return $this; | |
} | |
/** | |
* Move the cursor down. | |
*/ | |
protected function down($lines = 1) | |
{ | |
echo "\e[{$lines}B"; | |
return $this; | |
} | |
/** | |
* Move the cursor right. | |
*/ | |
protected function right($colums = 1) | |
{ | |
echo "\e[{$colums}C"; | |
return $this; | |
} | |
/** | |
* Move the cursor left. | |
*/ | |
protected function left($columns = 1) | |
{ | |
echo "\e[{$columns}D"; | |
return $this; | |
} | |
/** | |
* Clear the current line. | |
*/ | |
protected function clearLine() | |
{ | |
echo "\e[2K"; | |
return $this; | |
} | |
/** | |
* Hide the cursor. | |
*/ | |
protected function hideCursor() | |
{ | |
echo "\e[?25l"; | |
return $this; | |
} | |
/** | |
* Show the cursor. | |
*/ | |
protected function showCursor() | |
{ | |
echo "\e[?25h"; | |
return $this; | |
} | |
/** | |
* Eat the current cursor position. | |
*/ | |
protected function eat() | |
{ | |
echo '๐ฅ'; | |
return $this->left(2); | |
} | |
/** | |
* Give a cheeky grin. | |
*/ | |
protected function grin() | |
{ | |
echo '๐'; | |
return $this->left(2); | |
} | |
/** | |
* Pause until the "enter" key is pressed. | |
*/ | |
protected function pause() | |
{ | |
`read -s`; | |
return $this; | |
} | |
/** | |
* Sleep for the given number of seconds | |
*/ | |
protected function sleep($seconds) | |
{ | |
usleep($seconds * 1000 * 1000); | |
return $this; | |
} | |
/** | |
* Echo something cool to the screen. | |
*/ | |
protected function echoSomethingCool() | |
{ | |
echo "\e[38;2;255;45;32m"; | |
echo str_replace('โข', "\e[37mโข\e[38;2;255;45;32m", <<<'EOT' | |
โท โข โท โญโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฎ | |
โ โข โ โ โข โข โข โข โ โข โข โข โข โข โข โข โข โข โ โข โข โข โข โข โข โข โข โข โ โข โข โข โข โ | |
โ โข โ โ โข โญโโโฎ โข โ โข โญโโโโโโโโโค โข โญโโโฎ โข โ โข โญโโโโโโโโโฏ โข โญโโโฎ โข โ โข โญโโโฎ โข โ | |
โ โข โฐโโโโโโ โข โฐโโโฏ โข โ โข โ โ โข โฐโโโฏ โข โ โข โฐโโโโโโโโโค โข โฐโโโฏ โข โ โข โ โ โข โ | |
โ โข โข โข โข โข โญโโโฎ โข โข โข โ โ โข โญโโโฎ โข โข โข โข โข โข โ โข โข โข โข โข โข โ โ โข โ | |
โฐโโโโโโโโโโโโโโโโโโฏ โฐโโโโโโดโโโโโโฏ โฐโโโโโโฏ โฐโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโฏ โต โข โต | |
EOT); | |
echo "\e[39m"; // Reset foreground | |
return $this; | |
} | |
/** | |
* End with a bang! | |
*/ | |
protected function finale() | |
{ | |
echo PHP_EOL.PHP_EOL.PHP_EOL.PHP_EOL; | |
echo `lolcat -f --seed=10 --spread=14 << EOF | |
โขโฃดโฃถโฃฟโฃฟโฃฟโฃทโฃถโฃคโฃถโฃพโฃฟโฃฟโฃฟโฃถโฃฆโก | |
โขฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกฟ | |
โ โ ฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโ ฟโ | |
โ โ โ ปโขฟโฃฟโกฟโ โ โ | |
EOF`; | |
echo <<< 'EOF' | |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
โ โโโ โ โ โโโ โโโ โโโ โโโ โโโ โ โ โ | |
โ โ โโโ โโโ โโโ โโโ โ โโโ โโโ โ | |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
EOF; | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment