Skip to content

Instantly share code, notes, and snippets.

@jessarcher
Created August 8, 2023 22:56
Show Gist options
  • Save jessarcher/c4b9d8f5237d6158ec88d961986ebc6b to your computer and use it in GitHub Desktop.
Save jessarcher/c4b9d8f5237d6158ec88d961986ebc6b to your computer and use it in GitHub Desktop.
The `artisan thankyou` command from my Laracon US 2023 talk.
<?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