]> git.localhorst.tv Git - alttp.git/blob - app/Console/Commands/ChatlibGenerate.php
add myustery circus link
[alttp.git] / app / Console / Commands / ChatlibGenerate.php
1 <?php
2
3 namespace App\Console\Commands;
4
5 use App\Models\ChatLib;
6 use Illuminate\Console\Command;
7
8 class ChatlibGenerate extends Command {
9
10         /**
11          * The name and signature of the console command.
12          *
13          * @var string
14          */
15         protected $signature = 'chatlib:generate {which=de} {amount=50} {context?}';
16
17         /**
18          * The console command description.
19          *
20          * @var string
21          */
22         protected $description = 'Generates samples from a ChatLib database';
23
24         /**
25          * Execute the console command.
26          *
27          * @return int
28          */
29         public function handle() {
30
31                 $start = microtime(true);
32                 $this->line('loading database');
33                 $db = new ChatLib();
34                 $db->loadFrom($this->argument('which'));
35                 $this->line(
36                         number_format(microtime(true) - $start, 2).'s '.
37                         number_format(memory_get_usage() / 1024 / 1024, 3).'MB now '.
38                         number_format(memory_get_peak_usage() / 1024 / 1024, 3).'MB peak');
39
40                 $amount = intval($this->argument('amount'));
41                 for ($i = 0; $i < $amount; ++$i) {
42                         $this->line($db->generate($this->argument('context')));
43                 }
44
45                 return 0;
46         }
47
48 }
49
50 ?>