]> git.localhorst.tv Git - alttp.git/blobdiff - app/Console/Commands/ChatlibGenerate.php
cache chatlib databases
[alttp.git] / app / Console / Commands / ChatlibGenerate.php
diff --git a/app/Console/Commands/ChatlibGenerate.php b/app/Console/Commands/ChatlibGenerate.php
new file mode 100644 (file)
index 0000000..5ea85f6
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\ChatLib;
+use Illuminate\Console\Command;
+
+class ChatlibGenerate extends Command {
+
+       /**
+        * The name and signature of the console command.
+        *
+        * @var string
+        */
+       protected $signature = 'chatlib:generate {which=de} {amount=50}';
+
+       /**
+        * The console command description.
+        *
+        * @var string
+        */
+       protected $description = 'Generates samples from a ChatLib database';
+
+       /**
+        * Execute the console command.
+        *
+        * @return int
+        */
+       public function handle() {
+               $db = new ChatLib();
+               $db->loadFrom($this->argument('which'));
+
+               $amount = intval($this->argument('amount'));
+               for ($i = 0; $i < $amount; ++$i) {
+                       $this->line($db->generate());
+               }
+
+               return 0;
+       }
+
+}
+
+?>